C++ Program To Find Average Of Two Numbers
Write C++ Program to Find Average of Two Integer Numbers
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n1 , n2;
cout << "Enter the Number 1 :--> ";
cin >> n1;
cout << "Enter the Number 2 :--> ";
cin >> n2;
float avg = (n1 + n2) / (2.0);
cout << "Average: ("<< n1 <<" + " << n2 << ") / 2.0 " << " = " << avg;
return 0;
}
Output:
Enter the Number 1 :--> 55
Enter the Number 2 :--> 66
Average: (55 + 66) / 2.0 = 60.5