Computer Science, asked by ajaybiswa908, 18 days ago

Let's write a program to input the age of 5 students and calculate their average age​

Answers

Answered by VanXodus
1

Answer:

The following program in C++ takes the input and prints the average age of 5 students of a class.

Explanation:

#include <iostream.h>

main ()

{

int age1, age2, age3, age4, age5;

int TotalAge, AverageAge;

cout << “Please enter the age of student 1: ”;

cin >> age1;

cout << “Please enter the age of student 2: ”;

cin >> age2;

cout << “Please enter the age of student 3: ”;

cin >> age3;

cout << “Please enter the age of student 4: ”;

cin >> age4;

cout << “Please enter the age of student 5: ”;

cin >> age5;

TotalAge = age1 + age2 + age3 + age4 + age5;

AverageAge = TotalAge / 5;

cout << “Average age of class is: “ << AverageAge;

}

Hope this helps!

Please mark this as the brainliest answer :)

Similar questions