- 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.

22nd Feb 2022, 3:54 PM
Jojo Emeka
Jojo Emeka - avatar
10 Réponses
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; }
22nd Feb 2022, 4:14 PM
Avinesh
Avinesh - avatar
+ 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 👍
22nd Feb 2022, 4:04 PM
Ipang
+ 2
How about you write the code and share it along with your question and people will assist you reach the solution.
22nd Feb 2022, 3:58 PM
Avinesh
Avinesh - avatar
+ 2
oh okay Ipang
22nd Feb 2022, 4:05 PM
Jojo Emeka
Jojo Emeka - avatar
0
yes i'm using c++ CodeShow
22nd Feb 2022, 4:00 PM
Jojo Emeka
Jojo Emeka - avatar
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; }
22nd Feb 2022, 4:04 PM
Jojo Emeka
Jojo Emeka - avatar
0
thanks Avinesh
22nd Feb 2022, 4:16 PM
Jojo Emeka
Jojo Emeka - avatar
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; }
22nd Feb 2022, 5:48 PM
ZAKI MAX
ZAKI MAX - avatar
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; }
24th Feb 2022, 10:15 AM
Vipul Girhe
Vipul Girhe - avatar