Monday, February 16, 2009

Exercise05







#include
#include
void main(){clrscr(); int a,b,grade,sum,x,subject; float average; printf("Enter your Subject:"); scanf("%s",&subject); printf("Enter grade,-1 to exit:"); scanf("%d",&grade); if(grade!=-1 && grade>=95 && grade<=100) { printf("Enter grade;-1 to exit:"); scanf("%d",&a); sum=grade+a; average=sum/2; printf("Average is %.2f\n",average); printf("Rated A"); } if(grade!=-1 && grade>=90 && grade<=94) { printf("Enter grade;-1 to exit:"); scanf("%d",&a); sum=grade+a; average=sum/2; printf("Average is %.2f\n",average); printf("Rated B"); } if(grade!=-1 && grade>=85 && grade<=89) { printf("Enter grade;-1 to exit:"); scanf("%d",&a); sum=grade+a; average=sum/2; printf("Average is %.2f\n",average); printf("Rated C"); } if(grade!=-1 && grade>=80 && grade<=84) { printf("Enter grade;-1 to exit:"); scanf("%d",&a); sum=grade+a; average=sum/2; printf("Average is %.2f\n",average); printf("Rated D"); } if(grade!=-1 && grade>=75 && grade<=79) { printf("Enter grade;-1 to exit:"); scanf("%d",&a); sum=grade+a; average=sum/2; printf("Average is %.2f\n",average); printf("Rated E"); } if(grade!=-1 && grade<=74) { printf("SORRY YOUR FAILED IN THIS SUBJECT"); } else { if(grade==-x) printf("\"INVALID INPUT\""); } while(grade==-1) { printf("NO NUMBERS INPUTTED");} getch();}

No comments:

Post a Comment