+ 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
5 Respostas
+ 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.
+ 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.
+ 1
First try then ask
+ 1
#include <iostream>
using namespace std;
int main() {
int n=15;
cin >> n;
cout << "n\n";
;if (n&5){ cout << "beep";
}
return 0;
}
0
It tell me only one beep