The "it shows three lines" is because you forgot to close the curlies of your first if. If you insert '}' between r54 and r55, it'll probably work. The rest of your code shows some problems as well, so I'm quite confused it compiles at all...
in main() you have not initialised 'Choice', C, N or J. Hence they all hold undefined values. You have defined another, separate char called Choice in GetConcerts(), but this is only a local variable and is destroyed upon leaving the function, hence Choice, N, J, C are still undefined at the if statements.
You are also missing a } after the first if statement.
Not sure why leaving Choice, C, N, J undefined yields true in your if statement conditions though. But if you initialise these properly then the if statements should work.
*EDIT*
@Gaminic
Yep, your right, the semicolons are allowing for the intended body of your if statements to be executed unconditionally. If you remove them then none of them will be invoked at present because Choice, N, J and C have undefined values.
char GetConcert ()
{
char Choice;
cout << "The following upcoming concerts are scheduled for the Walton Center:\n";
cout << " C for Canadian Brass\n";
cout << " J for Julliard String Quartet\n";
cout << " N for NSync\n";
cout << "Enter the letter (in uppercase) for the concert you wish to attend: ";
cin >> Choice;
}
doesn't your compiler, at least, warn you?
you declared GetConcert() with a char return value but you didn't return a value at all... so it's should be:
1 2 3 4 5 6 7 8 9 10 11 12
char GetConcert ()
{
char Choice;
cout << "The following upcoming concerts are scheduled for the Walton Center:\n";
cout << " C for Canadian Brass\n";
cout << " J for Julliard String Quartet\n";
cout << " N for NSync\n";
cout << "Enter the letter (in uppercase) for the concert you wish to attend: ";
cin >> Choice;
return Choice;
}
second:
if (Choice==N); // the others have mentioned your mistake in here for a semicolon
the other mistake is, your if line compare a variable called Choice to a variable called N. you should write itlike this:
His compiler should also have errored out because there's an unclosed '{' in the code, i.e. the one from the first if() I pointed out, as well as the lack of return value in his function. What compiler/IDE are you using?
ultifinitus you act as if you troll as a female on the daily.:) would you be offended if someone called you a girl instead of guy? yeah.. i think one could make that assumption:)