0% found this document useful (0 votes)
4 views

basic

The document outlines a series of tasks for writing C programs that involve reading and printing integers and floating-point numbers using different methods. It includes exercises on formatting output, calculating averages, and performing arithmetic operations with an emphasis on operator precedence. Additionally, it covers swapping values between two integers.

Uploaded by

s36347032
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

basic

The document outlines a series of tasks for writing C programs that involve reading and printing integers and floating-point numbers using different methods. It includes exercises on formatting output, calculating averages, and performing arithmetic operations with an emphasis on operator precedence. Additionally, it covers swapping values between two integers.

Uploaded by

s36347032
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Write C programs to

1. Read two integers and two floating point numbers, each in a separate scanf() statement (so 4
scanf’s) and print them with separate printf statements (4 printf’s) with some message

2. Repeat 1, but now read all of them in a single scanf statement and print them in a single printf
statement

3. Repeat 1 and 2 with other data types like double and char

4. Repeat 1 and 2, but now print the real numbers with only 3 digits after the decimal point

5. Read 4 integers in a single scanf statement, and print them (using a single printf statement) in
separate lines such that the last digit of each integer is exactly 10 spaces away from the beginning of
the line it is printed in (the 9 spaces before will be occupied by blanks or other digits of the integer).
Remember that different integers can have different number of digits

6. Repeat 5, but now the first integer of each integer should be exactly 8 spaces away from the
beginning of the line it is printed in.

7. Read in three integers and print their average

8. Read in four integers a, b, c, d. Compute and print the value of the expression
a+b/c/d*10*5-b+20*d/c
• Explain to yourself the value printed based on precedence of operators taught
• Repeat by putting parenthesis around different parts (you choose) and first do by hand
what should be printed, and then run the program to verify if you got it right.

9. Swap the value of two integers a and b.

You might also like