Thursday, July 9, 2009

Is my grade program right? (c language). It doesnt seem to want to work.?

#include%26lt;stdio.h%26gt;


main()


{





char total, loop;


int grade,cout,name, number,a,b,c,d,f,avg





{


printf("enter students name");


scanf("%d",%26amp;name);


printf("enter the grade");


scanf("%d",%26amp;grade);


for (number=1;number%26lt;=grade;number++)


{


cout%26lt;%26lt;number%26lt;%26lt;": ";





name=name+grade;


if (grade%26gt;=90%26amp;%26amp;grade%26lt;=100)


a=a+1;


else if(grade%26gt;=80%26amp;%26amp;grade%26lt;=89)


b=b+1;


else if(grade%26gt;=70%26amp;%26amp;grade%26lt;=79)


c=c+1;


else if(grade%26gt;=60%26amp;%26amp;grade%26lt;=69)


d=d+1;


else if(grade%26lt;=59)


f=f+1;


}


{


printf("A's ",a);


printf("B's ",b);


printf("C's ",c);


printf("D's ",d);


printf("F's ",f);


printf("Average= ",avg) (" which is a/an ");total;





printf("\ndo you want to run again? ");


loop;


}


while (loop=='y');





return(0);


}

Is my grade program right? (c language). It doesnt seem to want to work.?
Some things are missing, or ... (?)





Where is the "do" statement for the do{ }while(loop=='y'); ?





and:





printf("\ndo you want to run again? ");


loop; // %26lt;- how does this get any input/change?





///does this next line compile? (I don't see how it could, or how it could execute if it did compile)


printf("Average= ",avg) (" which is a/an ");total;





These issues may seem small, but remember; C isn't like grammar or other subjects. There's no forgiveness or success for code that's "90% OK."
Reply:The problems of your code are the same as he said! And few others! Looks like you need to work on your code and syntax! You have some deep holes that if you do not fix now, you will end up hating C! go to www.cprogramming.com and get a copy of K%26amp;R second second version! Ansi C! read every tutorial on the site I gave you and then you will find all the mistakes in this code by yourself! :)

plum

No comments:

Post a Comment