944,154 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Unsolved
  • Views: 1356
  • C RSS
Jun 22nd, 2006
0

Hi to all! I just want to know if my code is right to calcute the quetelet? Thank you

Expand Post »
  1. #include<stdio.h>
  2. #include<conio.h>
  3. main()
  4. {
  5. float x,y,z;
  6. clrscr();
  7. printf("\nThis program calculate if you are Underweight,Healthy or Overweight");
  8. printf("\n\n Enter your weight in kilograms:");
  9. scanf("%f",&x);
  10. printf("\n\n Enter your weight in meters:");
  11. scanf("%f",&y);
  12. z=((y*y)/x);
  13. if(z<20){
  14. printf(" the Quetelet-index is: %f",z);
  15. printf("\n\n\tUnderweight");
  16. }
  17. else{
  18. printf("\n the quetelet-index is : %f",z);
  19. printf("\n\n\tOverweight");
  20. }
  21. getch();
  22. return 0;
  23. }

Last edited by Dave Sinkula; Jun 22nd, 2006 at 10:41 am.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
-jOHn BeneDict- is offline Offline
1 posts
since Jun 2006
Jun 22nd, 2006
0

Re: Hi to all! I just want to know if my code is right to calcute the quetelet? Thank you

I can't help you with the math (have no clue what a quetelet is) but you will need to add a getch() immediately following that scanf() to remove the <Enter> key from the keyboard buffer. scanf() does not do that for you.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2283
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,963 posts
since Aug 2005
Jun 28th, 2006
0

Re: Hi to all! I just want to know if my code is right to calcute the quetelet? Thank you

Yes, but fflush(stdin); will do as well...
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Shadowhawk is offline Offline
18 posts
since Jun 2005
Jun 28th, 2006
0

Re: Hi to all! I just want to know if my code is right to calcute the quetelet? Thank

Quote originally posted by Shadowhawk ...
Yes, but fflush(stdin); will do as well...
No! No! No! No! No! NO!!!

http://c-faq.com/stdio/stdinflush.html
Last edited by Dave Sinkula; Jun 28th, 2006 at 11:37 am.
Team Colleague
Reputation Points: 2780
Solved Threads: 312
long time no c
Dave Sinkula is offline Offline
4,790 posts
since Apr 2004
Jul 9th, 2006
0

Re: Hi to all! I just want to know if my code is right to calcute the quetelet? Thank

Quote originally posted by Dave Sinkula ...
No! No! No! No! No! NO!!!
OK, I didn't know that... Sorry, I have tried it once or twice, and it worked on my compiler... What can I say... I feel ashamed....
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Shadowhawk is offline Offline
18 posts
since Jun 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C Forum Timeline: swapping
Next Thread in C Forum Timeline: pls check flowchart for errors/inefficiencies





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC