1 /*surface area of cylindrical body. CPP:2 Problem Description: Enter the radius of the cylinder R and H, the surface area of the output cylinder S. Hint: π value directly write 3.14159263 */ 4 5#include"stdafx.h" 6 7 8 intMain ()9 { Ten floatR, H, A; Oneprintf"Input the radius and height of the cylinder.\n"); Ascanf_s ("%f \%f", &r, &h); - -A =2*3.1415926f* R * H +2*3.1415926f* R *R; the -printf"\ n the surface area of the cylinder is%f", A); - - + return 0; -}
Feelings:
1. The function printf and scanf structures are very similar:
printf ("Output format", variable 1, ..., variable n);
scanf ("Output format",& variable 1,......,& variable n);
As can be seen, the difference between the two grammars lies in the ampersand before the variables. ( Why is this?) )
2.
3.1415926f
If you discard F, the compiler defaults to double type data, which can result in data loss. (What is the specific loss?) )
"C Language and Programming" Project 1-4-2-4: Calculate cylinder surface area