Pseudo-code algorithm
i need help writing a Pseudo-code algorithm for this basic function code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
|
#include <iostream>
#include <cstdlib>
#include <iomanip>
using namespace std;
int sumnumbers(int num, int &sum, bool send);
void dispavg(double average);
int main()
{
int num;
int sum = 0;
int count = 0;
cout << fixed << showpoint << setprecision(1);
while (true) {
cout << "Enter an interger, (ctrl+z to display average): ";
if (!(cin >> num)) break;
(count = 0.0);
sumnumbers(num, sum, false);
}
dispavg((double)sum / sumnumbers(num, sum, true));
system("pause");
return 0;
}
int sumnumbers(int num, int &sum, bool send)
{
static int count = 0;
if (send)
return count;
else
{
sum += num;
count++;
}
cout <<"The sum is " << sum << endl;
return 0;
}
void dispavg(double average)
{
cout << "The Average is " << average << endl;
}
|
> writing a Pseudo-code algorithm for this basic function code
that's kind of backwards.
first step, indent the code properly
Topic archived. No new replies allowed.