write a program ,enter five subject marks to calculate the total and average in C++
Answers
Answered by
15
To calculate average and percentage marks of a student in C++ programming, you have to ask to the user to enter marks obtained in some number of subjects (5 subjects here).
Place summation of 5 subject's marks in a variable say sum and place sum/5 in a variable say avg (average of 5 subjects) then place sum/500*100 in a variable say perc (percentage marks), then display the result on the screen as shown here in the following program.
C++ Programming Code to Calculate Average Percentage Marks
Following C++ program ask to the user to enter the marks obtained in 5 subjects to calculate and display the average and percentage marks :
/* C++ Program - Calculate Average and Percentage Marks */
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int mark[5], i;
float sum=0;
cout<<"Enter marks obtained in Physics, Chemistry, Maths, CS, English :";
for(i=0; i<5; i++)
{
cin>>mark[i];
sum=sum+mark[i];
}
float avg=sum/5;
float perc;
perc=(sum/500)*100;
cout<<"Average Marks = "<<avg;
cout<<"\nPercentage = "<<perc<<"%";
getch();
}
I hope it is helped you
follow me
Place summation of 5 subject's marks in a variable say sum and place sum/5 in a variable say avg (average of 5 subjects) then place sum/500*100 in a variable say perc (percentage marks), then display the result on the screen as shown here in the following program.
C++ Programming Code to Calculate Average Percentage Marks
Following C++ program ask to the user to enter the marks obtained in 5 subjects to calculate and display the average and percentage marks :
/* C++ Program - Calculate Average and Percentage Marks */
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int mark[5], i;
float sum=0;
cout<<"Enter marks obtained in Physics, Chemistry, Maths, CS, English :";
for(i=0; i<5; i++)
{
cin>>mark[i];
sum=sum+mark[i];
}
float avg=sum/5;
float perc;
perc=(sum/500)*100;
cout<<"Average Marks = "<<avg;
cout<<"\nPercentage = "<<perc<<"%";
getch();
}
I hope it is helped you
follow me
jannatzubair71:
please give me the program to calculate the total and average not percentage
Answered by
4
If you like it follow me and punch the brainiest button in the face
Attachments:
Similar questions