Write the algorithm and pseudocode for finding the average of five(5) numbers.
#include <bits/stdc++.h>
using namespace std;
double a, b, c, d, e;
int main()
{
cin >> a >> b >> c >> d >> e;
double avg = (a+b+c+d+e)/5;
cout << "Average: " << avg;
return 0;
}
Pseudocode:
Initializing five variables a, b, c, d, e;
Finding the average avg = (a+b+c+d+e) / 5;
Printing the result (avg);
Sample Input 1:
2 3 1 4 5
Sample Output 1:
3
Sample Input 2:
2 2 1 5 7
Sample Output 2:
3.4
Comments
Leave a comment