View Single Post
Old 10-11-2006, 09:44 PM   #20
ValdisSeroff

Join Date
Oct 2005
Posts
566
Senior Member
Default
It looks good, you're almost there.

As for your question, to make the scanf() function accept letters instead of numbers, change the format parameter (1st parameter) to "%c", which means single character (%d means decimal integer). Then use an "if" statement to test if the character is a "y" or "n"

So, the code (with changes in bold) should look something like this:

Code: [code]void main() { int a,b,c,d,h,z; while(a!=2){ char y; printf("Please make a choice\n"); printf("1-Grade Calculation\n"); printf("2-END\n"); scanf("%d", &a); if (a==1){ printf("Please enter your first grade:"); scanf("%d", &b); printf("\n"); printf("Please enter your second grade:"); scanf("%d", &c); printf("\n"); printf("Please enter your third grade:"); scanf("%d", &d); printf("The average is:"); h=(b+c+d)/3; printf("%d", h); printf("\n"); <b>if(h>=90 && h=80 && h=70 && h=60 && h=0 && h
ValdisSeroff is offline


 

All times are GMT +1. The time now is 07:48 PM.
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Design & Developed by Amodity.com
Copyright© Amodity