I need to make a program that will determine an odd or even number and when I try to assign a value to "int o" or "int e" it says o and e are "uninitialized local variable 'name' used". The thing is I have to use a "ternary/conditional operator" and I'm unfamiliar with this.
#include <iostream>
usingnamespace std;
int main()
{
int digit;
int solution;
int o, e;
cout << "Please enter a number for me to determine if it is odd or even " << endl;
cin >> digit;
solution = digit % 2 == 0 ? solution = e : solution = o;
if (solution = e)
{
cout << "The number you input is even " << endl;
}
else
{
cout << "The number you input is odd " << endl;
}
return 0;
}
int main()
{
int digit;
bool solution;
cout << "Please enter a number for me to determine if it is odd or even " << endl;
cin >> digit;
solution = digit % 2 ? false : true;
if (solution)
{
cout << "The number you input is even " << endl;)