+ 1

Can someone help

#include <iostream> using namespace std; int main() { int n; cin >> n; //your code goes here return 0; } Input 12 Sample output: 12 11 10 Beep 9 8 7 6 5 Beep 4 3 2 1

12th Apr 2021, 10:09 AM
RIP VIP
RIP VIP - avatar
5 Answers
+ 2
First of all no need to declare n=15; You have to use a for loop like that: for (int i=n;i<0;i--) { cout<<i<<endl; //some code } for getting the reminder you have to use % module not &. Your if statement should be like that: if (i%5==0){ cout<<"Beep"<<endl;//The first letter of Beep should be capital and not "n" it should be "i" ,if you declare i in the for loop. } The if statement must be inside the for loop.It is your work to set up.
12th Apr 2021, 10:54 AM
The future is now thanks to science
The future is now thanks to science - avatar
+ 1
First you have to show your attempt .We can't give you the direct code. Short explanation: print from input number to 1.(use \n to print the number to next line) When the number is divided by 5 do Beep.
12th Apr 2021, 10:13 AM
The future is now thanks to science
The future is now thanks to science - avatar
+ 1
First try then ask
12th Apr 2021, 10:17 AM
Matias
Matias - avatar
+ 1
#include <iostream> using namespace std; int main() { int n=15; cin >> n; cout << "n\n"; ;if (n&5){ cout << "beep"; } return 0; }
12th Apr 2021, 10:43 AM
RIP VIP
RIP VIP - avatar
0
It tell me only one beep
12th Apr 2021, 11:07 AM
RIP VIP
RIP VIP - avatar