Countdown Timer

Hi! Anyone here can help me to make a countdown timer?
I have the idea to use x-- as decrement but it don't have the delay.
@ryanjoshiii

You could add #include <Windows.h> That has a Sleep function. To use it, you add Sleep(1000); for a one second delay, since Sleep uses milliseconds. Adjust the 1000 to however long or short, a delay you need.
How's this sir @whitenite1?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <iostream>
#include <conio.h>
#include <Windows.h>
using namespace std;

int main() 
{
    int n = 15;

    while (n>0) {
      cout << n << " secs";
      --n;
    Sleep(1000);
    }

getch ();
return 0;
}
@ryanjoshiii

Not bad. You may want a newline in there somewhere so the text is printed on different lines each time.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <iostream>
#include <conio.h>
#include <Windows.h>
using namespace std;

int main() 
{
    int n = 15;

    while (n>0) {
      cout << n << " secs\n"; // Newline added
      --n;
    Sleep(1000);
    }

getch ();
return 0;
}
Topic archived. No new replies allowed.