0

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

Hey guys I'm beginner here and don't know how to do this every time I tried I got so many numbers in negative part. Can someone please help me.

3rd Nov 2020, 11:09 AM
𝓢𝓽𝓪𝓻𝓵𝓲𝓰𝓱𝓽 𝓟𝓻𝓲𝓽𝓲
27 Antworten
+ 29
I think this is something what you're looking for! https://code.sololearn.com/cUWS8NP8FWTD/?ref=app
6th Nov 2020, 3:28 AM
Saurabh
Saurabh - avatar
+ 13
package main import "fmt" func ( x *Timer ) tick(){ x.id++ fmt.Println(x.id) } type Timer struct { value string id int } func main() { var x int fmt.Scanln(&x) t := Timer{"timer1", 0} for i:=0;i<x;i++ { t.tick() } }
3rd Jul 2021, 11:09 PM
Alsadiq Almahdi
Alsadiq Almahdi - avatar
+ 5
C++/C Challenger✔️✅☑️ Thank you so much sir for your help ☺️☺️
6th Nov 2020, 6:25 AM
𝓢𝓽𝓪𝓻𝓵𝓲𝓰𝓱𝓽 𝓟𝓻𝓲𝓽𝓲
+ 4
Look in the beginning of the course to learn about 'input' and 'loops'
3rd Nov 2020, 11:13 AM
Olivia
Olivia - avatar
+ 4
# take the number as input number = int(input()) #use a while loop for the countdown while number >=0:print(number);number = number - 1
6th Nov 2023, 3:29 AM
Minhaj Zaidi
Minhaj Zaidi - avatar
+ 3
You can either use a for loop or add a second condition to stop seconds below 0
3rd Nov 2020, 11:17 AM
Olivia
Olivia - avatar
+ 3
create code on your language and link on your code, better remove this topic and create new topic with code , question and link on your code. In code will write comment “what do you want to do”example: input and output
3rd Nov 2020, 11:21 AM
Sergey
Sergey - avatar
+ 3
#include <iostream> using namespace std; int main() { int seconds; cin >> seconds; while (seconds >= 0){ cout <<"timer : "<<seconds<<endl; seconds=seconds -1; } return 0; }
9th Mar 2021, 10:17 PM
Funny videos mix
Funny videos mix - avatar
+ 2
Nasif Rahman #include <iostream> using namespace std; int main() { int seconds = 3 ; while (seconds < 4){ cout << seconds << endl ; seconds = seconds - 1; } return 0; }
3rd Nov 2020, 11:15 AM
𝓢𝓽𝓪𝓻𝓵𝓲𝓰𝓱𝓽 𝓟𝓻𝓲𝓽𝓲
+ 2
Olivia I tried but i got nothing There's nothing about it
3rd Nov 2020, 11:17 AM
𝓢𝓽𝓪𝓻𝓵𝓲𝓰𝓱𝓽 𝓟𝓻𝓲𝓽𝓲
+ 2
Ticking Timer You are building a Timer app that should count up to a given number. Your program needs to take a number as input and make the Timer tick that number of times. The code in main initializes a Timer and takes a number as input. Then it calls the tick() method for the Timer the given number of times. Define the Timer struct with two fields: id and value, and define the tick() method, which should increment the value by one and output its current value. package main import "fmt" func main() { var x int fmt.Scanln(&x) t := Timer{"timer1", 0} for i:=0;i<x;i++ { t.tick() } } can anyone answer it in golang please
2nd Jul 2021, 6:05 AM
Gagan Baghel
Gagan Baghel - avatar
+ 2
#include <iostream> using namespace std; int main() { int seconds; cin>>seconds; //your code goes here while (seconds >= 0) { cout << seconds << endl; seconds--; } return 0; }
20th Sep 2021, 5:21 PM
Malik Mehrab Rashid
Malik Mehrab Rashid - avatar
+ 2
// thank me later #include <iostream> using namespace std; int main() { int seconds; cin >> seconds; while (0 <= seconds){ cout << seconds << endl; seconds--; } return 0; }
7th Nov 2021, 9:23 AM
Gregorius Steven
Gregorius Steven - avatar
+ 2
At python -------------------- # take the number as input number = int(input()) #use a while loop for the countdown while number >= 0: print(number) number -= 1
13th Jun 2023, 12:23 AM
Mushfiqur Rahman
Mushfiqur Rahman - avatar
+ 1
Olivia some examples please
3rd Nov 2020, 11:18 AM
𝓢𝓽𝓪𝓻𝓵𝓲𝓰𝓱𝓽 𝓟𝓻𝓲𝓽𝓲
+ 1
#include <iostream> using namespace std; int main() { int seconds; cin>>seconds; //your code goes here cout << seconds << endl; while (seconds > 0){ seconds --; cout << seconds << endl; } return 0; }
7th Sep 2021, 10:06 AM
Bruce Daine M. Sison
Bruce Daine M. Sison - avatar
+ 1
let num = parseInt(readLine(), 10); //your code goes here while (num > -1) { console.log(num); num--; } using javascript
2nd Apr 2023, 4:08 PM
Esraa Salah Ali
+ 1
number =int(input()) while number>=0: print(number) number=number-1
22nd Aug 2023, 10:59 AM
Sesodhar Reddy
Sesodhar Reddy - avatar
+ 1
# take the number as input number = int(input()) #use a while loop for the countdown while number in reversed(range(4)): print(number) number = number - 1 while number in reversed(range(6)): print(number) number = number - 1
29th Aug 2023, 9:58 AM
Nomvuyiso Banya
+ 1
# take the number as input number = int(input()) #use a while loop for the countdown
16th Nov 2023, 7:01 PM
Singa Uday Kumar Reddy
Singa Uday Kumar Reddy - avatar