Hello, I have to ask a user to enter integers or to enter q to quit. I have written a program that finally allows the user to enter q without the program entering an infinite loop. Now I am unable to enter the number 0 without triggering my break.
How can I allow the user to enter 0 so that it applies towards total and q to quit the program?
This is for a midterm and has to remain simple.
Thank you
Code:
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int integer = 0;
int count = 0;
int total = 0;
int odd = 0;
do
{
cout << "Enter integer (q to quit): ";
cin >> integer;
if (integer == false)
{
break;
}
if (integer % 2 == 1)
{
cout << "we have an odd" << "\n";
odd++;
total += integer;
}
} while (integer == true || integer >= 0 || integer <= 0);
cout << "Odd = " << odd << endl;
cout << "Total = " << total << endl;
cout << "Goodbye!";
return 0;
}