Boolean Functions

#include <iostream>

using namespace std;

int main()
{
int n, count;
float sum, avg;

sum = 0;
cout << "How many numbers? ";
cin >> n;

int a;
for (count=1; count<=n; count++) {
cout << "Enter Number: ";
cin >> a;
sum = sum + a;
}
cout << "The sum is " << sum << endl;
avg = sum / n;
cout << "The average is " << avg << endl;

return 0;
}


i want to make this program after each number entry, the program will ask me to continiue(until i press no it will count) with boolean function how it works ?
Last edited on
bool keepgoing()
{
return pressedno(); //whatever press no means to you, typed in? Button?
...
or
if(pressedno())
return true;
return false;
... etc
}

they work just like any other function, except they return "true", "false", or the result of a comparison operation (return x==y is possible)
Topic archived. No new replies allowed.