0

#include <stdio.h> int main() { printf("Color: %s, Number: %d, float: %5.2f \n", "red", 42, 3.14159);

why my float out put is 3.14?

10th Mar 2020, 8:36 PM
sagor zia
sagor zia - avatar
4 odpowiedzi
+ 5
You wrote .2. That means 2 decimal places.
10th Mar 2020, 8:39 PM
HonFu
HonFu - avatar
+ 4
%5.2f that number 2 is the reason why your number has two decimal places. https://code.sololearn.com/crf7R7QxVRqW/?ref=app
10th Mar 2020, 8:39 PM
voja
voja - avatar
+ 3
That defines the width on with your number is placed. Try it out with larger values, you'll quickly see what it does!
10th Mar 2020, 8:42 PM
HonFu
HonFu - avatar
0
what is the use of 5 then?
10th Mar 2020, 8:39 PM
sagor zia
sagor zia - avatar