Quantcast

Got Homework?

Connect with other students for help. It's a free community.

  • across
    MIT Grad Student
    Online now
  • laura*
    Helped 1,000 students
    Online now
  • Hero
    College Math Guru
    Online now

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

anurag_1812

#include<stdio.h> int main() { float f1 = 14.375; float f2 = 14.385; if(f1 == 14.375) printf("YES\n"); else printf("NO\n"); if(f2 == 14.385) printf("YES\n"); else printf("NO\n"); return 0; }

  • one year ago
  • one year ago

  • This Question is Open
  1. anurag_1812
    Best Response
    You've already chosen the best response.
    Medals 0

    what should be the o/p of this code and why? thnks in advance.

    • one year ago
  2. hedjm
    Best Response
    You've already chosen the best response.
    Medals 0

    Hi, try to use the debugger to see the actual values in memory see the Attach file (an image from my debugger VC++) You can see that the actual value for f2 is: 14.3850002

    • one year ago
    1 Attachment
  3. hedjm
    Best Response
    You've already chosen the best response.
    Medals 0

    try to use: f to compare with the exact precision ok see this code: #include<stdio.h> #include<float.h> using namespace std; int main() { float f1 = 14.375; float f2 = 14.385; if(f1 == 14.375f) printf("YES\n"); else printf("NO\n"); if(f2 == 14.385f) printf("YES\n"); else printf("NO\n"); return 0; }

    • one year ago
  4. fitsyu
    Best Response
    You've already chosen the best response.
    Medals 0

    YES YES

    • one year ago
  5. classicalyomi
    Best Response
    You've already chosen the best response.
    Medals 0

    Yes Yes

    • one year ago
    • Attachments:

See more questions >>>

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.