Question regarding the \n command | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Question regarding the \n command

int main() { cout << "C \n"; cout << "+ \n"; cout << "+"; This code gives me the same end results as the code Practice shows me (C + + in diffefent lines), but my code is nowhere the same as the "correct" way. Why did I still get the end result?

7th Apr 2022, 1:38 PM
socialism
4 Answers
+ 2
Is it asked to put spaces before new line? Check for that in description.
7th Apr 2022, 1:48 PM
Jayakrishna 🇮🇳
+ 1
It is. I realise I used the command in the wrong way, or at least differently than it was intended as shown in the results, but I still have got the output correct and thats whats bothering me! The practice tool doesnt see it as being solved tho, when I run the code and go to results, the input part is shown to be empty but both output parts are the same.
7th Apr 2022, 1:57 PM
socialism
+ 1
Try this: int main() { cout << "C\n"; cout << "+\n"; cout << "+"; } and reply
7th Apr 2022, 2:29 PM
Jayakrishna 🇮🇳
+ 1
Sololearn does not check your code. All it does is look at the output and compare it to the expected output. If it is identical it is accepted as correct. But it has to be exactly identical including spelling, whitespace, rounding, ...
7th Apr 2022, 8:26 PM
Simon Sauter
Simon Sauter - avatar