- 1
can anyone help me with this task please.
countdown. i need to make a countdown 'app'. given a number N as input, output numbers from N to 1 on separate lines. Also, when the current countdown number is a multiple of 5, the app should output 'beep'. Please make the code as clear as possible.
10 Respuestas
0
If you have not found the solution yet then you can refer the below.
#include <iostream>
using namespace std;
int main(){
int A;
cin >> A;
int B=1;
while (B<=A){
if (B%5==0) {
cout<< "Beep" << endl;
}
else{
cout<< B << endl;
}
B++;
}
return 0;
}
+ 3
Jojo,
You csn search the forum using 'countdown' search term. This coach task had been brought up many times, so there should already been a solution or at least clues to solve it 👍
+ 2
How about you write the code and share it along with your question and people will assist you reach the solution.
+ 2
oh okay Ipang
0
yes i'm using c++
CodeShow
0
Avinesh #include <iostream>
using namespace std;
int main()
{
int A;
cin >> A;
int B=1;
int C=A%5;
while (B<=A){ cout<< A<< endl; A--;}
if (C==0) { cout<< "Beep" << endl ;}
return 0;
}
0
thanks Avinesh
0
if you want where it multiple 5
show it and beep
#include <iostream>
using namespace std;
int main() {
int n ;
cout<<"please enter a number \n ";
cin >> n ;
for ( int i = n ; i >0 ; i-- ){
if (n % 5 == 0 ){
cout << i << " beep "<<endl ;
}
else {
cout<<i<<endl ;
}
}
return 0;
}
0
#include <iostream>
using namespace std;
int main() {
int n;
cin>> n ;
while (n>0){
if (n%5 ==0){
cout << n <<endl << "Beep \n";
}
else {
cout << n << endl ;
}
n--;
}
return 0;
}