1. Write a C++ program to calculate average marks scored by a student for 3 subjects.
C++ program to calculate average marks
#include
#include
void main()
{clrscr();
float a,b,c,average;
couta>>b>>c;
average= (a+b+c)/5
cout
#include
void main()
{clrscr();
float a,b,c,average;
couta>>b>>c;
average= (a+b+c)/5
cout
#include<stdio.h>
#include<conio.h>
void main()
{
int sum,no;
int I,j,k;
float avg;
int std_marks[100];
clrscr();
sum=0;
printf("Please enter the number of student appear in the examination n::");
scanf("%d",&no);
printf("Please enter the marks of %d student one by onen",no);
for(I=1;I<=no;I++)
{
scanf("%d",&std_marks[I]);
}
for(j=1;j<=no;j++)
{
sum=sum+std_marks[j];
}
avg=sum/no;
printf("The marks of the students are as followsn");
for(k=1;k<=no;k++)
{
printf("nRoll NO =%d marks %d",k,std_marks[k]);
}
printf("nnnThe average marks is %f",avg);
getch();
}
#include<conio.h>
void main()
{
int sum,no;
int I,j,k;
float avg;
int std_marks[100];
clrscr();
sum=0;
printf("Please enter the number of student appear in the examination n::");
scanf("%d",&no);
printf("Please enter the marks of %d student one by onen",no);
for(I=1;I<=no;I++)
{
scanf("%d",&std_marks[I]);
}
for(j=1;j<=no;j++)
{
sum=sum+std_marks[j];
}
avg=sum/no;
printf("The marks of the students are as followsn");
for(k=1;k<=no;k++)
{
printf("nRoll NO =%d marks %d",k,std_marks[k]);
}
printf("nnnThe average marks is %f",avg);
getch();
}