New course! Every coder should learn Generative AI!
Try a free lesson0
Is there anyone help me to write a code for this problem please
You 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".
4 Answers
+ 2
abel p Yes we can help but show attempts.
+ 2
abel p
There is no n multiple of 5. This is not an exam where you can write anything and get number. It's a programming. You need to learn.
Use for loop or while loop and print number in reverse order and also check if number % 5 == 0 and print "Beep" if condition is satisfied.
Complete the course, do more practice and then solve problem.
+ 1
The question means to output number from N to 1, where N is user's input. So you need a loop to output the numbers counting down N times.
Also, to check weather the number is multiple of 5, you can check if the number's remainder is 0.
0
#include <iostream>
using namespace std;
int main() {
int n;
cin >> n;
//your code goes here
if ( n <=15 && n multiple of 5 ) {
cout << "beep";
}
return 0;