Hi, I think my problem is the while loop is only running once but I am confused as to how to fix it... Not 100 % sure that's the problem I am very beginner
#include <iostream>
#include <string>
using namespace std;
string evenOrOdd (int number) {
string answer;
if ((number % 2) == 0) {
answer = "Even";
}
else {
answer = "Odd";
}
return answer;
}
int main () {
string answer;
int number = 1;
while (number != 0) {
cout << "Enter a number: ";
cin >> number;
cout << number;
cout << endl;
if (number != 0) {
answer = evenOrOdd (number);
cout << number << " is " << answer << endl;
}
if (number = 0) {
cout << "Good bye!";
}
}
return 0;
}
Launch Terminal
0001: Enter~a~number:~11
0002: 11~is~Odd
0003: [NONE]
=================== MISMATCH FOUND ON LINE 0003: ===================
ACTUAL : [NONE]
EXPECTED: Enter~a~number:~12
======================================================