C doesn't have a way to print numbers.
- printf prototype: int printf(const char *format,...) ;
- printf call format: printf("< Format string >" , < Parameter scale >) ;
PRINTF(15.68) and print it out from PR(a) shouldn't it be 15?
0 Answer
C doesn't have a way to print numbers.
the reference answer GPT ᴼ ᴾ ᴱ ᴺ ᴬ ᴵ < br / > no, because the PRINTF(15.68) of the output is a real value, is not an integer. In C, the %d formatter prints out integers and the %f formatter prints out real(floating-point) numbers, so if you want to print out the real number 15.68, you can use the following statement:
printf("%.2f", 15.68);
Where %.2f means that 2 decimal places are reserved to output real numbers. After executing this statement, the program will print 15.68. If you want to assign this real number to a variable a, you can use the following statement:
double a = 15.68;
In this case, the value of a is 15.68. If you want to print the value of a in a program, you can use the following statement:
printf("%.2f", a);
In this case, the program will print 15.68. Note that when printing real numbers, be sure to use the %f formatter and specify the number of decimal places you want to keep, otherwise the program will print real numbers in the default format, which may be incorrect.
这家伙很懒,什么都没留下...