C program: Find the Average marks of a student in his exams. This sample simple program discuss about calculating individual subject marks and averaging it by the C source code. It is a simple source program to understand easily. It can be used in all LAB exams and theory exams also.
[Related: Learn English Quickly] & [Love % Calculator]
AVERAGE MARK OF STUDENTS IN C
Find out the average of marks of a student in C. It is used to find the students average mark and pass or fail details. It is useful for college students, school and any tutorial center students by calculating average using if…else if… statement (conditional statements).
C PROGRAM:
/* Title: Calculate Program Author: Vinoth © http://students3k.com This website provides lots of useful information for all students. */ //Header files #include<stdio.h> #include<conio.h> void main() { //PROGRAM VARIABLES char b; int s1,g,h,s,m,e; float c; clrscr(); //Function to clear previous output printf("ENTER THE NAME:------"); //Display function scanf("%c",&b); //Getting input function printf("ENTER THE MARK IN ENG::--"); scanf("%d",&e); printf("ENTER THE MARK IN MATH::---- "); scanf("%d",&m); printf("ENTER THE MARK IN SCI::---- "); scanf("%d",&s); printf("ENTER THE MARK IN HIS::---- "); scanf("%d",&h); printf("ENTER THE MARK IN GEOGRAPHY::---- "); scanf("%d",&g); s1=e+m+s+h+g+s; c=s1/5; if (c>=60) //Conditional statement(if…elseif) { printf("THE NAME IS --\n\t\t\t\t\t\t%c\n",a); printf("\t\t\t\t-----------------------------\n"); printf("\n\t\t\tTHE MARK SECURED IN ENG-%d\n\t\t\tTHE MARK SECURED IN MATH-%d\n\t\t\tTHE MARK SECURED IN SCI-%d\n\t\t\tTHE MARK SECURED IN HISTORY-%d\n\t\t\tTHE MARK SECURED IN GEO-%d\n",e,m,s,h,g); printf("\n\t\t\t%c STANDS IN FIRST DIVISION",b); } else if((c>=50) && (c<60)) { printf("\THE NAME IS ---\n\t\t\t\t\t\t%c\n",b); printf("-----------------------------"); printf("\n\t\t\tTHE MARK SECURED IN ENG-%d\n\t\t\tTHE MARK SECURED IN MATH-%d\n\t\t\tTHE MARK SECURED IN SCI-%d\n\t\t\tTHE MARK SECURED IN HISTORY-%d\n\t\t\tTHE MARK SECURED IN GEO-%d\n",e,m,s,h,g); printf("\n\t\t\t%c STANDS IN SECOND DIVISION",b); } else if((c>=40) && (c<50)) { printf("THE STUDENT NAME IS ---\n\t\t\t\t\t\t%c\n",b); printf("-----------------------------\n"); printf("\n\t\t\tTHE MARK SECURED IN ENG-%d\n\t\t\tTHE MARK SECURED IN MATH-%d\n\t\t\tTHE MARK SECURED IN SCI-%d\n\t\t\tTHE MARK SECURED IN HISTORY-%d\n\t\t\tTHE MARK SECURED IN GEO-%d\n",e,m,s,h,g); printf("\n\t\t\t%c STANDS IN THIRD DIVISION",b); } else { printf("THE NAME IS ---\n\t\t\t\t\t\t%c\n",b); printf("-----------------------------"); printf("\n\t\t\tTHE MARK SECURED IN ENG-%d\n THE MARK SECURED IN MATH-%d\n\t\t\t THE MARK SECURED IN SCI-%d\n\t\t\t THE MARK SECURED IN HIS-%d\n\t\t\t THE MARK SECURED IN GEO-%d\n",e,m,s,h,g); printf("\n\t\t\t%c FAIL TO PASS",b); } getch(); }