input and output | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

input and output

in the part formatting output there are these number 3.2, 8.5, -8.5 in the example print out Pi. what is the meaning?

12th Aug 2020, 7:13 AM
Jason Nguyen
Jason Nguyen - avatar
1 Answer
+ 6
Decimal numbers can have up to 15 decimal spaces and you may sometimes want to round them. The lesson offers an easy way to round floats: printf("Pi = %8.5f", 3.14159); %8.5f means that the float will be rounded to 5 decimal numbers, and if the integer part has less than 8 digits, they will be replaced with spaces.
12th Aug 2020, 7:52 AM
Seb TheS
Seb TheS - avatar