Program in C++ to read three numbers and compute their average

The below program will accept three numbers from the user, compute their average and display it.

#include <iostream>
#include "conio.h"
using namespace std;

void main() 
{
 int m1, m2, m3;
 float avg;

 cout << "Enter 3 numbers" << endl;
 cin >> m1 >> m2 >> m3;

 avg = (m1 + m2 + m3) / 3;

 cout << "Average = " << avg << endl;

 getch();
}

Output:

Enter 3 numbers
10 20 30 
Average = 20

Note: The above program is written and tested using Microsoft Visual Studio 2008

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *