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'"

30th Jun 2021, 7:33 AM
Global Long
Global Long - avatar
2 ответов
+ 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; }
30th Jun 2021, 8:23 AM
Simba
Simba - avatar
+ 1
You have to go in reverse order suppose n is 12 then it should be 12 11 10 Beep 9 8 7 .. ..
30th Jun 2021, 7:40 AM
A S Raghuvanshi
A S Raghuvanshi - avatar