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

Please support our C advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Jun 2006
Posts: 1
Reputation: -jOHn BeneDict- is an unknown quantity at this point 
Solved Threads: 0
-jOHn BeneDict- -jOHn BeneDict- is offline Offline
Newbie Poster

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

 
0
  #1
Jun 22nd, 2006
  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.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,413
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1470
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

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

 
0
  #2
Jun 22nd, 2006
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.
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 12
Reputation: Shadowhawk is an unknown quantity at this point 
Solved Threads: 0
Shadowhawk's Avatar
Shadowhawk Shadowhawk is offline Offline
Newbie Poster

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

 
0
  #3
Jun 28th, 2006
Yes, but fflush(stdin); will do as well...
Reply With Quote Quick reply to this message  
Join Date: Apr 2004
Posts: 4,362
Reputation: Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future 
Solved Threads: 241
Team Colleague
Dave Sinkula's Avatar
Dave Sinkula Dave Sinkula is offline Offline
long time no c

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

 
0
  #4
Jun 28th, 2006
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.
"One of the methods used by statists to destroy capitalism consists in establishing controls that tie a given industry hand and foot, making it unable to solve its problems, then declaring that freedom has failed and stronger controls are necessary." --Ayn Rand
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 12
Reputation: Shadowhawk is an unknown quantity at this point 
Solved Threads: 0
Shadowhawk's Avatar
Shadowhawk Shadowhawk is offline Offline
Newbie Poster

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

 
0
  #5
Jul 9th, 2006
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....
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC