For each of the code fragments below, combine the printf statements into single printf statement.
Code | Combined printf | Output |
---|---|---|
printf("\n");
printf("Welcome.\n");
|
printf("\nWelcome.\n"); |
Enter-'Welcome.'-Enter |
int n = 42;
printf("%i", n);
printf(".\n");
|
printf("%i.\n", n); |
`42.`-Enter |
int n = 3;
printf("The square of ");
printf("%i", n);
printf(" is ");
printf("%i", n*n);
printf(".\n");
|
printf("The square of %i is %i.\n", n, n*n); |
`The square of 3 is 9.'-Enter |
int n = 25;
printf("%i", n);
printf(" = ");
printf("%i", n - (n%10));
printf(" + ");
printf("%i", n%10);
|
printf("%i = %i + %i", n, n - (n%10), n%10); |
25 = 20 + 5 |
int a = 2, b = 3;
printf("The sum of ")
printf("%i", a);
printf(" and ");
printf("%i", b);
printf(" is ");
printf("%i", a+b);
printf(".\n");
|
printf("The sum of %i and %i is %i.\n", a, b, a+b); |
`The sum of 2 and 3 is 5.`-Enter |