Example of C progamming language

Try this in turbo C:-

#include<stdio.h>
#include<conio.h>
void main()
{
    float a=0.7;
    if(0.7>a)
      printf("aa");
    else
      printf("bb");
   getch();
}

Output : aa

The if statement goes for true part but why...??
Answer for this that 0.7 is stored in the memory as 0.699999988079071.
Therefore if statement goes for true part.

Check another example by typing this small code :


#include<stdio.h>
#include<conio.h>
void main()
{
    float a=0.3;
    printf("%.20f",a);
    getch();
}

You will get output as :  0.29999999999999998890
Here 0.3 is stored as 0.29999999999999998890 in the memory

About the author

Admin
Donec non enim in turpis pulvinar facilisis. Ut felis. Praesent dapibus, neque id cursus faucibus. Aenean fermentum, eget tincidunt.

0 comments:

Template by Clairvo Yance
Copyright © 2012 Enigma of IT and Blogger Themes.