Displaying exercises/e2/solution/math.c#include <stdio.h>
/**
* Replace all the ?'s so that this becomes a working program:
*/
int main(void)
{
// Define two integers to hold the a and b values:
int a, b;
// Modify the printf to print the prompt: a?
printf("a? ");
// Note how there is no newline at the end, this leaves the cursor on the same line
// as the prompt so the scanf will read the integer you type just after the prompt.
// Modify the scanf to read an integer into the variable a:
scanf("%d", &a);
// We don't check that scanf is successful (user could have entered a non-integer),
// but we probably should check.
// Modify the printf to print the prompt: b?
printf("b? ");
// Modify the scanf to read an integer into the variable b:
scanf("%d", &b);
// Complete the printf:
printf("%d + %d = %d\n", a, b, a+b);
return 0;
}
|