+ 1
Can someone explain to me why these small changes (countdown proj) made a difference?
I had the same correct results/output for all the cases for both code, but the 2nd code was the one that passed....why? Does that really matter? //Results same but code that didn't pass: int main() { int n; cin >> n; while (n>=1){ cout<<n<<endl; if (n % 5 == 0){ cout << "Beep \n"; } n--; } return 0; } //Code that passed (only deleted spaces in n % 5 == 0 & changed to "Beep" << endl : int main() { int n; cin >> n; while (n>=1){ cout<<n<<endl; if (n%5== 0){ cout << "Beep" << endl; } n--; } return 0; } Edit: Ok ty Tina. Got it 👍
1 Resposta
+ 3
milkcereal
whitespaces in source code doesn't matter at all, however the problem is in the output, "Beep " and "Beep" are different, at least the first one is 5 bytes, the second is 4 (note the space) . that's the problem.
it's not a big deal in this case however, logically thinking and from a programming point of view your code produces wrong results and that's the first thing you should taking care of.
if you do cout << "Beep\n" ; it will pass.