|
Hey, I'm teaching myself how to use C++ before I start my term of it in January.
This is my second code I've completed and I have one problem that I can't figure out... I know it's going to be an easy answer for the majority of you guys to figure out, so any help would be appreciated.
Thanks.
--------------------------------------------------
#include <iostream>
using namespace std;
int main()
{
int d, remainder;
char answer;
part1:
cout << "Please Enter a number to determine if the number is even or odd: ";
cin >> d;
cout << "Are you sure about this number???";
cout << " (y or n) " ;
cin >> answer;
if (answer = y)
{
cout << "Thank you" << endl;
system ("pause");
goto part2;
}
if (answer = n)
{
cout << "Lets try this again" << endl;
system ("pause");
goto part1;
}
else
cout << "Error" << endl << "Please Try again" << endl;
system ("pause");
goto part1;
part2:
remainder = d%2;
if (d%2==0)
{
cout << "The number is even";
cout << "\n";
}
else
{
cout << "The number is odd";
cout << "\n";
}
system ("pause");
return 0;
}
--------------------------------------
|
|
|
|
|
|
|
// |