a LITTLE help!

Pages: 12
hi?
Last edited on
Your if syntax is wrong. It goes like this:

1
2
3
4
if (condition) // No ';'
{
  //Statements go here
}


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...
I took the semicolons out and it's still doing the same exact error.. it does compile and i am able to make selections.
Hi
What do you think your GetConcert() function is doing?
Hint: it doesn't alter the value of the variable Choice ;)

*EDIT*
Or rather it does, but not the one declared in main().
Last edited on
Hi cindyath,

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.
Last edited on
i apologize* i did exactly as you said and it's doing the same thing. Can i ask how there is problem in my code?
here's your another two mistakes...
1
2
3
4
5
6
7
8
9
10
11
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:

 
if (Choice == 'N')


and that's applied for the rest of ifs...
Last edited on
test.
Last edited on
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?
Her compiler*!!!! :)
Nearly there: you're returning the value of GetConcert(), but it's not being saved.

Change line 50 to "Choice = GetConcert();" and it should work.
Last edited on
i love you all. sincerely
Don't forget to flag it as "solved".
oh so you're a girl... nice to know you... :"> (blushing face)
oh so you're a girl... nice to know you... :"> (blushing face)


Why do some guys become so socially awkward when they find girls online?
hahaha...
...that was bad, chipp.
---
oh so you're a girl... nice to know you... :"> (blushing face)

Or someone is trolling or just wants help faster. It's quite a bit easier to get help online with a female personage with attitudes like yours.
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:)
also, wtf @ cindyath

Why did you erase your posts. That's a grade A jerk move. It's like you just wasted everyone's time and effort.
Pages: 12