0

If I put the value of n equal to 15 and I want my output like this 15,beep,14,13,12,11,10,beep,9,8,7,6,5,beep,4,3,2,1

But i didn't not get what I want can anyone explain me https://code.sololearn.com/c52XM9lVj1Rw/?ref=app

28th May 2022, 1:15 PM
Rakhi Mittal
4 Answers
+ 3
Also there is "Beep" not "beep"
28th May 2022, 3:24 PM
A͢J
A͢J - avatar
+ 2
Oh yes , thank you
28th May 2022, 2:29 PM
Rakhi Mittal
+ 1
#include <iostream> using namespace std; int main() { int n; cin >> n; //your code goes here while(n>=1){ cout<<n<<","; if(n%5==0){ cout<<"beep,"; } n--; } return 0; }
28th May 2022, 1:23 PM
Mihir Lalwani
Mihir Lalwani - avatar
0
Hello. You have to place n-- after the "if" statement. The reasoning is that: 1.You write the number 2.Check if the number % to 5 == 0 3.THEN decrease it. The way you are doing it now is: 1.Write the number 2.Decrease it 3.Check if the number(-1, because you decreased it) % 5 == 0
28th May 2022, 1:17 PM
🍇 Alex Tușinean 💜
🍇 Alex Tușinean 💜 - avatar