I have problem with the code
double d;
int i;
float f ;
long l;
i=l=f=d=100;
printf(“%.8g\t”,(double)i);
The output comes 33 instead of 33.33333
Why and what is the significance of %.8g
I have problem with the code
double d;
int i;
float f ;
long l;
i=l=f=d=100;
printf(“%.8g\t”,(double)i);
The output comes 33 instead of 33.33333
Why and what is the significance of %.8g
EmbLogic Research & Competency Development Labs
Phone: +91 9818467776, 8527567776, 9650467776
Email: info@emblogic.com
Copyright © EmbLogic Embedded Technologies Pvt. Ltd.
i=l=f=d=100/3
the o/p is 33 because 100/3 is an integer division (by default)
for 33.3333, the division should be 100./3
%g represents float value
.8 is used to round the ans till 8 places of decimal (no significance in this quest.)