+ 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; }
4 Respuestas
+ 3
you have an unexpected space between "Beep" and "\n"... it should be: "Beep\n", not "Beep \n" ^^
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;
}
0
You can also try deleting the space between ‘Beep’ and ‘\n’
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;
}