Program that calculates the average of three notes

Programa que calcula a média de três notas
Program that calculates the average of three notes

In the 1st semester of 2012, in the TSIN course at Uninove, the teacher asked for a program that calculated the average of three grades for a student. The program was written in C on DEV C++.

Download the Program that averages three grades

NOTE: If you want to see an example of a program that calculates the average of three grades discarding the grade with the lowest value between n1 and n2, click here!

Here is the source code of the Program that calculates the average of three grades

#include #include main(){ char op; do{ float n1=11,n2=11,n3=11,average; printf("\tFabio Bmed TSIN Uninove - www.fabiobmed.com.br\n\tProgram calculates average of 3 grades\n\n"); //NOTE 1 while((n1>10) || (n1<0)){ printf("\tEnter the first note: "); scanf("%f",&n1); if ((n1>10) || (n1<0)){ printf("\tIncorrect grade. Please enter a grade between 1 and 10:\n\n"); } else{ break; } } //NOTE 2 while((n2>10) || (n2<0)){ printf("\tEnter the second note: "); scanf("%f",&n2); if ((n2>10) || (n2<0)){ printf("\tIncorrect grade. Please enter a grade between 1 and 10:\n\n"); } else{ break; } } //NOTE 3 while((n3>10) || (n3<0)){ printf("\tEnter the third note: "); scanf("%f",&n3); if ((n3>10) || (n3<0)){ printf("\tIncorrect grade. Please enter a grade between 1 and 10:\n\n"); } else{ break; } } mean=(n1+n2+n3)/3; printf("\n\tNote 1: %.2f \n\tNote 2: %.2f \n\tNote 3: %.2f \n\n\tThe media e: %.2f\n\n",n1, n2,n3,average); printf("\tDo you want to calculate a new average? Y - Continue | N - Exit: "); getchar(); scanf("%c",&op); system("cls"); } while(op == 's'); }

Fabio Bmed TSIN Uninove Class 2012

 601 Total Visualizações,  1 Visualizações Hoje

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.