Write a C program to print out the sum of two numbers in the form
The sum of 3 and 4 was 7
I.e. display the numbers as well as their sum.
Modify the program of exercise 1 to obtain the two numbers interactively from the user.
By specifying a plus-sign in the
scanf()
format write a program that will read in simple sums such as
12+34
and print the result.
Write a program that declares at least three variables and initialises them to fairly large values. By suitable use of the
printf()
layout print them out in a neat column.
If the symbol "-" appears immediately after the "%" in a d conversion specification for use by printf() then the displayed number is left-justified within the output field rather than the usual right justification. Write a program to demonstrate this, can you think of any use for this facility ?
If the symbol "+" appears immediately after the "%" in a d conversion specification for use by printf() then the number displayed is always preceded by a sign. Write a program to demonstrate this, can you think of any use for this facility ?