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


Example:
Input: 3


Expected Output:
3
2
1
0

------------------------------

In Python3

# take the number as input number = int(input()) #use a while loop for the countdown while number >= 0: print(number) number -= 1

--------------------------

In JS

let num = parseInt(readLine(), 10); //your code goes here while (num > -1) { console.log(num); num--; }

--------------

In C++


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


















Next Post Previous Post
No Comment
Add Comment
comment url