Please help , urgent c++ question

Stop spamming the forum please.
Peace.
It's not that your program isn't working... it is. The only thing that isn't working is the display of your menus.

In DisplayMenuSelections() you have the following lines:
1
2
3
4
5
if(num==0) {
	cout << "NOT YET SET" << endl << endl;
} else {
	cout << num << endl << endl;
}

and
1
2
3
4
5
if(num !=0) {
	cout << "2.) Test for sign." << endl;
	cout << "3.) Test for even/odd." << endl;
	cout << "4.) Test for primality." << endl;
}


The menus are treating 0 as an invalid case.

The solution:
Initialize num to some crazy number:
int num = 0xdeadbeef;

Then when you check to see if num has been set, use that number:
1
2
3
4
5
if(num==0xdeadbeef) {
	cout << "NOT YET SET" << endl << endl;
} else {
	cout << num << endl << endl;
}

and
1
2
3
4
5
if(num !=0xdeadbeef) {
	cout << "2.) Test for sign." << endl;
	cout << "3.) Test for even/odd." << endl;
	cout << "4.) Test for primality." << endl;
}


By the way, I really like how you hide invalid menu options. It's creative!
Last edited on
Topic archived. No new replies allowed.