0
Code not run
#include <iostream> using namespace std; int main() { int n; cin >> n; for (int i = 0; i <= n; i++) { cout << i << endl; if (i ℅ 5 == 0 ) { cout << "beep" << endl; } } return 0; } My code not run at "cout << "beep" << endl;" And " Expected ')' before 'u00002105'"
2 Respostas
+ 3
You used `℅` symbol instead of `%` for modulus operator. [if (i % 5 == 0 )]
Also B should be uppercase in `Beep`
#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" << endl;
}
}
return 0;
}
+ 1
You have to go in reverse order suppose n is 12 then it should be
12
11
10
Beep
9
8
7
..
..