+ 2

Create a timer program that will take the number of seconds as input, output the remaining time and countdown to 0.

Create a timer program that will take the number of seconds as input, output the remaining time and countdown to 0. You need to output every number, including 0.

15th Feb 2022, 2:22 PM
Andi Pantea
5 odpowiedzi
+ 1
Heya, I got the right answer using this but i think there are better ways to do it #include <iostream> using namespace std; int main() { int n; cin >> n; int x; int r; for (x = n; x > 0; x--) { cout << x << endl; r = x % 5; if (r == 0 ) {cout << "Beep"<< endl;} } return 0; }
22nd Feb 2022, 3:43 PM
Justin Maloney
+ 3
Use a for loop. int seconds = 7; //for example for(seconds; seconds >=0; seconds--) { std::cout << seconds; }
15th Feb 2022, 3:59 PM
The_Fox
The_Fox - avatar
+ 1
#include <iostream> using namespace std; int main() { int n; cin >> n; int x; int r; for (x = n; x > 0; x--) { cout << x << endl; r = x % 5; if (r == 0 ) {cout << "Beep"<< endl;} } return 0; }
1st Jan 2023, 9:16 AM
ZARIF JORAYEV
ZARIF JORAYEV - avatar
+ 1
#include <iostream> using namespace std; int main() { int seconds; cin >> seconds; while (0 <= seconds){ cout << seconds << endl; seconds--; } return 0; }
1st Jan 2023, 9:36 AM
ZARIF JORAYEV
ZARIF JORAYEV - avatar
0
what is the program?
2nd Sep 2023, 5:54 AM
NARESH M
NARESH M - avatar