In the second example, the sequence ``%f'' is used to print the value of an integer variable. What will happen? The program will print some random floating point value. The programmer should have used ``%d'' instead to print the value of total.
The third statement is really confused! It looks like the programmer is trying to give more than one control string to printf. Here is a corrected version of the third statement:
printf("The roots are %f and %f.\n", root1, root2);
Finally, the fourth statement is missing an argument to printf. The control string tells printf that it should expect three more arguments-and integer and two floating point numbers. But the programmer has apparently forgotten to include root2 in the argument list. What will happen? The program will probably print some random value for the second root.
Return to lesson.