Can someone help | Sololearn: Learn to code for FREE!


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

4/12/2021 10:09:32 AM


5 Answers

New Answer


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.


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.


First try then ask


#include <iostream> using namespace std; int main() { int n=15; cin >> n; cout << "n\n"; ;if (n&5){ cout << "beep"; } return 0; }


It tell me only one beep