Computer Science, asked by priyakhosla634, 1 year ago

Write a c++ program that accepts marks in 5 subjects and outputs average marks

Answers

Answered by lovingheart
3

A c++ program that accepts marks in 5 subjects and outputs average marks:

#include<iostream.h>

#include<conio.h>

void main()

{

clrscr();

int marks[5], i;

float Total=0;

cout<<"Enter marks obtained in English, Tamil, Maths, Science, Social :";

for(i=0; i<5; i++)

{

 cin>>marks[i];

 Total=Total+marks[i];

}

float averag=Total/5;

cout<<"Average Marks = "<<average;

getch();

}

This program obtains the marks of five subject in an array by running a for loop and obtain values from the user during run time. Then, each mark is added to the total. Once all the marks are added the average is found using the formula total / 5 and then it is printed.

Similar questions