Chapter 22.4 Answers
* Calculate and display the sum of two input variables.
* Extra comments have been added to explain each line.
* (One wouldnt normally have so many comments.)
#include <.h> /* define standard I/O */
int main(void) /* start of main program */
int first, second; /* two input variables */
printf(Enter two integers: ); /* prompt for input */
scanf(%d%d, &first, &second); /* get the input */
/* echo the input and display the sum, all in one line: */
printf(%d + %d = %d\n, first, second, first + second);
return(0); /* return to the O/S */
char mychar; /* input character */
float myfloat; /* input floating-point number */
printf(Enter a character and a floating-point number: );
scanf(%c%f, &mychar, &myfloat);
printf(You entered %c and %f\n, mychar, myfloat);