How it gets "zero".. after 3.14 | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How it gets "zero".. after 3.14

#include <stdio.h> int main() { const double PI = 3.14; printf("%f", PI); return 0; }

1st Apr 2021, 1:51 PM
S M Rakibul Alam
S M Rakibul Alam - avatar
1 Answer
+ 4
If you don't want the zeroes then use "%.2lf" as format specifier .2 defines 2 digits fraction lf defines double type More on this topic you can read from here 👇 http://www.cplusplus.com/reference/cstdio/scanf/ http://www.cplusplus.com/reference/cstdio/printf/
1st Apr 2021, 2:12 PM
Ipang