+ 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); }
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.
+ 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.
+ 2
Bloody Halos thank you so much I fixed that then realized I needed some more spaces and it worked. Thanks again