creating a timer using in C++

In the program, while-loop, for-loop and if-else statement are used.

It also uses _setcursortype (0) which does not allow the mouse cursor to be shown from the screen.


In the program, the body of while-loop is a for-loop while the body of this for-loop is if-else statements, here is blue-print-


The program will take input from the user in minutes and will start count down according to the given input.

Here is the Program,

#include<string.h> // strcpy
#include<stdlib.h> //atoi, exit()
#include<stdio.h> // remove
void main() { clrscr(); int n; char c; cout<<"Enter the number(minute) to be start counting: "; cin>>n; int j=n; _setcursortype(0); //_setcursortype(NOCURSOR); also work while(j>=0) { for(int i=0;i<20;i++) { cout<<"\n\n\n\n\n"<<setw(35)<<"\n"; if(i<10) { c = '0'; cout<<"\t\t\t 0"<<j<<" : "<<c<<i; } else if(i>9) cout<<"\t\t\t 0"<<j<<" : "<<i; cout<<"\n"<<setw(35)<<"%%%%%%%%%%%\n"; delay(100); clrscr(); if(j==0&&i==19) { cout<<"\n\n\n\n\t\ttime up...."; } }j--; } getch(); }
Enter the number(minute) to be start counting: 2 

02:00 %%%%%%%%%%%

Here is the output,