Home > Back-end > Are learning c language, a don't understand the problems
Are learning c language, a don't understand the problems
Time:09-17
# include Void main () { Int a, b, c, Max, min, The scanf (" % d % d % d ", & amp; A, & amp; B, & amp; C); Int sum=a + b + c, ji=a * b * c; If (a> B) { Max=a; Min=b; } The else { Max=b; Min=a; } If (max> C) Printf (" Max=% d \ n ", Max). The else Printf (" Max=% d \ n ", c); If (minPrintf (" min=% d \ n ", min); The else Printf (" min=% d \ n ", c); Printf (" sum=% d \ n ", sum); printf (" average=% f \ n ", the sum/3.0); printf (" \ n=% d ", ji); }
CodePudding user response:
Printf (" average=% f \ n ", the sum/3.0); With printf (" average=% f \ n ", the sum/3); Or printf (" average=% d \ n ", the sum/3.0); Is wrong, this is why?
CodePudding user response:
Int the sum, sum/3 are integers, sum/3.0 is a floating point number,
CodePudding user response:
"/" to the operators in the use of the C inside
You with printf (" average=% f \ n ", the sum/3.0); Or printf (" average=% d \ n ", the sum/3); Look at the results
CodePudding user response:
# define _CRT_SECURE_NO_WARNINGS 1
# include #include
Int main () { Float a, b, c, Max, min, sum, ji. Printf (" please enter the number three: "); The scanf (" % f % f % f ", & amp; A, & amp; B, & amp; C); Sum=a + b + c, ji=a * b * c;
If (a> B) { Max=a; Min=b; } The else { Max=b; Min=a; }
If (max> C) Printf (" Max=% 2 f \ n ", Max). The else Printf (" Max=% 2 f \ n ", c);
If (minPrintf (" min=% 2 f \ n ", min); The else Printf (" min=% 2 f \ n ", c);
Printf (" sum=% 2 f \ n ", sum); Printf (" average=% 2 f \ n ", the sum/3.0); Printf (" product=% 2 f \ n ", ji); system("pause"); return 0; }