Trying to make in countdown from 3 2 1 0 | Sololearn: Learn to code for FREE!

+1

Trying to make in countdown from 3 2 1 0

#include <iostream> using namespace std; int main() { int seconds; cin>>seconds; while (seconds <= 5){ seconds--; } return 0; }

c++

9/17/2021 10:24:06 AM

Mando

8 Answers

New Answer

+4

You can do something like this: while (seconds >= 0){ cout<<seconds<<endl; seconds--; }

+1

If you want to make a delay between each second so it won't print instantly- read about the thread and chrono modules in C++.

0

Didnt work

0

Mando can you please describe your problem a little bit more..?

0

rupali 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. Sample Input 5 Sample Input 5 4 3 2 1 0

0

Mando hope it helps... https://code.sololearn.com/czY93PlDQW1t/?ref=app

0

Thanks

0

#include <iostream> using namespace std; int main() { int seconds; cin >> seconds; if(seconds == 4){ while(seconds){ seconds--; cout << seconds << endl; } } else{ cout << "invalid input"; } return 0; } PS: if you want to count down from all numbers just remove the if statment