help plz…………..

Home Forums C Programming help plz…………..

This topic contains 1 reply, has 2 voices, and was last updated by  LenoraRamsey 8 years, 10 months ago.

  • Author
    Posts
  • #2242

    #include
    void main()
    {
    long double a =0;
    if(a>float(0))
    printf(“hi”);
    else
    printf(“hello”);
    )

    why it outputs hello ………….plz explain ………………

  • #3640

    LenoraRamsey
    Member

    Actually, In C float and double has only two differences. one is size. and another one is storage in memory.
    float has only single precision. But double has double precision.

    So, In your code you are trying to differentiate this. But it gives output as hello because it is equal.
    double 0 is equal to float 0.

    If you want differentiate float and double try this code.

    It will prints hi.

    It will prints hello.

    I think now you can get the difference.

You must be logged in to reply to this topic.

0 Shares
Share
Tweet
Share
Pin
+1