+ 1

Countdown project

Hey guys! I am having an issue with the code I wrote for the countdown project. It runs perfectly fine when I run it on my IDE but for some reason, SoloLearn doesn't accept it as a valid answer. Any clue why? #include <iostream> using namespace std; int main() { int N; cin >> N ; for ( int i= N ; i >=1; i--) { cout << i << endl ; if (i % 5 == 0){ cout << "Beep \n" ; } } return 0; }

11th Jul 2021, 2:27 AM
Layla Xholi
4 Respuestas
+ 3
you have an unexpected space between "Beep" and "\n"... it should be: "Beep\n", not "Beep \n" ^^
11th Jul 2021, 2:32 AM
visph
visph - avatar
0
Try #include <iostream> using namespace std; int main() { int n; cin >> n; do { cout << n << endl; if (n % 5 ==0) { cout << "Beep" << endl; } n--; } while (n > 0); return 0; }
20th Sep 2021, 10:18 PM
Rahinatu Ako Husnah
Rahinatu Ako Husnah  - avatar
0
You can also try deleting the space between ‘Beep’ and ‘\n’
20th Sep 2021, 10:22 PM
Rahinatu Ako Husnah
Rahinatu Ako Husnah  - avatar
0
#include <iostream> using namespace std; int main() { int n; cin >> n; //your code goes here for(int i=n;i>=1;i--){ if(i%5==0){ cout <<i<<endl; cout<<"Beep"<<endl; } else{ cout <<i<<endl; } } return 0; }
16th Apr 2022, 10:16 PM
april mahlatsi motaung
april mahlatsi motaung - avatar