Program to calculate sum,average of marks in C Language

Introduction: In previous articles i explained the program for How to find month name corresponding to number using switch case in C Language and  How to find week days corresponding to number using switch case in C Language and Else if ladder or multiple else if to check the day corresponding to number in C Language  and Else if ladder or multiple else if to check the month of entered number in C language.
In this post i have written a program to calculate the total and average of student's  marks.It will first prompt user to enter name,class,roll number and marks in each subject.Then it will calculate the total marks obtained and the average of marks.

Let's create a program to understand.

#include<conio.h>
#include<stdio.h>

main()
{
      char name[25];
      int roll,clas;
      float hindi,eng,math,sci,art,comp,total,avg;
      clrscr();
      printf("Enter name of student:=");
      scanf("%s",&name);
      printf("Enter class of student:=");
      scanf("%d",&clas);
      printf("Enter rollno of student:=");
      scanf("%d",&roll);
      printf("Enter marks in hindi:=");
      scanf("%f",&hindi);
      printf("Enter marks in english:=");
      scanf("%f",&eng);
      printf("Enter marks in math:=");
      scanf("%f",&math);
      printf("Enter marks in science:=");
      scanf("%f",&sci);
      printf("Enter marks in art:=");
      scanf("%f",&art);
      printf("Enter marks in computers:=");
      scanf("%f",&comp);
      total=hindi+eng+math+sci+art+comp;
      avg=total/6;
      printf("\n************Student's Marks Record*************\n");
      printf("Student's name=%s",name);
      printf("\nclass=%d",clas);
      printf("\nRoll No=%d",roll);
      printf("\nMarks in Hindi=%.0f",hindi);
      printf("\nMarks in English=%.0f",eng);
      printf("\nMarks in Math=%.0f",math);
      printf("\nMarks in Science=%.0f",sci);
      printf("\nMarks in Computer=%.0f",comp);
      printf("\nTotal Marks=%.0f",total);
      printf("\nAverage Marks=%.2f",avg);
      getch();
      }

Output:

Enter name of student:=Karan
Enter class of student:=12
Enter rollno of student:=18
Enter marks in hindi:=77
Enter marks in english:=67
Enter marks in math:=80
Enter marks in science:=75
Enter marks in arts=68
Enter marks in computer:=88

****************Student's Marks Record****************
Student's name:=Karan
Class:=12
Roll No:=18
Marks in Hindi:=77
Marks in English:=67
Marks in Math:=80
Marks in Science:=75
Marks in Art:=68
Marks in Computer:=88
Total Marks:=455
Average Marks:=75.833336

Previous
Next Post »

If you have any question about any post, Feel free to ask.You can simply drop a comment below post or contact via Contact Us form. Your feedback and suggestions will be highly appreciated. Also try to leave comments from your account not from the anonymous account so that i can respond to you easily..