C++ program to calculate sum,average of marks of student

Introduction: In previous articles i explained the program  for How to find month name corresponding to number using switch case and  How to find week day corresponding to number using switch case in C++ Language and  Else if ladder or multiple else if to check the day corresponding to number and Else if ladder or multiple else if to check the month corresponding to number .

In this post i have written a program to calculate the total marks obtained  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<iostream.h>
main()
{
      clrscr();
      char name[25];
      int roll,clas;
      float hindi,eng,math,sci,art,comp,total,avg;
      cout<<"Enter name of student:= ";
      cin>>name;
      cout<<"Enter class of student:=";
      cin>>clas;
      cout<<"Enter rollno of student:=";
      cin>>roll;
      cout<<"Enter marks in hindi:=";
      cin>>hindi;
      cout<<"Enter marks in english:=";
      cin>>eng;
      cout<<"Enter marks in math:=";
      cin>>math;
      cout<<"Enter marks in science:=";
      cin>>sci;
      cout<<"Enter marks in art:=";
      cin>>art;
      cout<<"Enter marks in computers:=";
      cin>>comp;
      total=hindi+eng+math+sci+art+comp;
      avg=total/6;
      cout<<"\n************Student's Marks Record*********************\n";
      cout<<"Student's name:="<<name;
      cout<<"\nClass:="<<clas;
      cout<<"\nRoll No:="<<roll;
      cout<<"\nMarks in Hindi:="<<hindi;
      cout<<"\nMarks in English:="<<eng;
      cout<<"\nMarks in Math:="<<math;
      cout<<"\nMarks in Science:="<<sci;
      cout<<"\nMarks in Art:="<<art;
      cout<<"\nMarks in computer="<<comp;
      cout<<"\nTotal Marks:="<<total;
      cout<<"\nAverage Marks="<<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..