By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,257 Members | 2,812 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,257 IT Pros & Developers. It's quick & easy.

the following code does not accepts floating number and i want input in same order

P: 1
Expand|Select|Wrap|Line Numbers
  1. #include<stdio.h>
  2. #include<conio.h>
  3. void main()
  4. {
  5. int r;
  6. char g;
  7. float p;
  8. clrscr();
  9. printf("enter your rollno.");
  10. scanf("%d",&r);
  11. printf("enter your grade");
  12. fflush(stdin);
  13. scanf("%c",&g);
  14. printf("enter your percentage\n");
  15. scanf("%f",&p);
  16. printf("your rollno.is %d\n",r);
  17. printf("your grade is %c\n",g);
  18. printf("your percentage is %f",p);
  19. getch();
  20. }
  21.  
Oct 1 '10 #1
Share this Question
Share on Google+
1 Reply


Expert 100+
P: 2,400
Compare lines 7 and 15. I believe the "%f" format in scanf requires a double argument, not a float. Same for line 18 and printf.
Oct 1 '10 #2

Post your reply

Sign in to post your reply or Sign up for a free account.