Programming Step 5
Figure out what kind of output will be required by the program. In this case, we want to print the number of grams. Since, the variable grams has the data type of float, use the print format function printf with a floating point format conversion character (“%f”). To dress up the output a little, we can include some text to describe the answer, and add a newline character (\n) to advance the cursor to the next line:
printf(“The total weight in grams is %f\n”, grams);