+ 1

[Solved] Where is the problem/mistake?

I was doing the code coach at the end of the lesson "Function Parameters" in the functions section and I tried some code and it didn't work and I couldn't understand why, so then I tried to copy the solution but I must have copied wrong because evrytime i run it says in the test cases "your output: 'no output' ". Somone please help me. Code: #include <iostream> using namespace std; void bot(int mode, string name) { if(mode == 1) { cout << "Welcome," << cout << name "!"; } else if(mode == 2) { cout << "Goodbye," << name << "!"; } else { cout << "Try again"; } } int main() { int mode; cin >> mode; string name; cin >> name; bot(mode, name); }

1st Jan 2023, 12:27 AM
bluish-poet
bluish-poet - avatar
3 odpowiedzi
+ 4
The first cout statement is missing a << operator toward the end. Also, shouldn't there be a space after the commas? The provided example programs are not always complete solutions.
1st Jan 2023, 12:42 AM
Brian
Brian - avatar
+ 4
In your mode 1 block, you have extra cout. And need << between name and "!" Like you have in mode 2 block. If you put name where the extra cout is, you should be fine.
1st Jan 2023, 12:36 AM
Bloody Halos
Bloody Halos - avatar
+ 2
Bloody Halos thank you so much I fixed that then realized I needed some more spaces and it worked. Thanks again
1st Jan 2023, 12:40 AM
bluish-poet
bluish-poet - avatar