Well your haphazard approach to using { } to mark blocks of code (and general poor indentation to start with) means that your code returns almost immediately without doing anything.
if ( num <= 1 )
cout << "Please Enter another number: " <<endl;
return 0;
You might think the return 0 is part of the if, but it isn't.
Whereas you may have meant
if ( num <= 1 ) {
cout << "Please Enter another number: " <<endl;
return 0;
}
If you always use { } even in the places where they're not strictly necessary, you'll save a hell of a lot of time (and confusion) when the code starts doing weird stuff because you forgot the single statement rule.
Salem
Posting Sage
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953