Wednesday, 11 September 2013

Blank string in c++

Blank string in c++

#include <iostream>
#include <string>
using namespace std;
int main()
{
int userInput;
string numberType;
cout << "Enter a number and I will Check to see if it is odd or even" <<
endl;
cin >> userInput;
if (userInput % 2 == 0)
{
string numberType = "Even";
}
else
{
string numberType = "Odd";
}
cout << "The number you input is " << numberType << endl;
return 0;
}
I'm trying to output the manipulated string value but the string that's
output in the last line comes out blank?

No comments:

Post a Comment