Let the future tell the truth and evaluate each one according to his work and accomplishments. The present is theirs; the future, for which I really worked, is mine. (Nikola Tesla)

19/06/2010

●Finding Average Score of Exams in C



int main(){

int rate1,rate2,rate3,score1,score2,score3;char a;int rate4,score4;int total,t1,t2,t3,t4;
printf("Is there any quiz/homework?\nIf Yes enter 'y' else 'n' and push enter\n");
a=getchar();
printf("\nEnter the first midterm's percantage ");
scanf("%d",&rate1);
printf("Enter the second midterm's percantage ");
scanf("%d",&rate2);
printf("Enter the final's percantage ");
scanf("%d",&rate3);
if(a=='y'){
printf("Enter the quiz/homework's percantage ");
scanf("%d",&rate4);}
printf("\nEnter the first midterm's score ");
scanf("%d",&score1);
printf("Enter the second midterm's score ");
scanf("%d",&score2);
printf("Enter the final's score ");
scanf("%d",&score3);
if(a=='y'){
printf("Enter the quiz/homework's score ");
scanf("%d",&score4); }

t1=0.01*rate1*score1;
t2=0.01*rate2*score2;
t3=0.01*rate3*score3;
t4=0.01*rate4*score4;

total=t1+t2+t3+t4;

printf("\nYour average score is %d\n\n",total);

}

ShareThis