Question #14119

(simulation clock countdown ). Write a program that prompts the user to enter the number of seconds to be counted down. Display a message each second of the countdown and include an additional warning every five seconds. Terminate when the time expires.

Expert's answer

#include <conio.h>
#include <iostream>
using namespace std;
int numberofseconds=0;
int main(){
int countforwarning=0;
cout<<"Enter the number of seconds to be counted down: ";
cin>>numberofseconds;
for(int i=0;i<5000000000;i++){
if(i0000000==1){
cout<<numberofseconds<<"
";
numberofseconds--;
countforwarning++;
if(countforwarning>0 && countforwarning%5==0){
cout<<"
An additional warning
";
}
if(numberofseconds<0){
break;
}

}
}
getch();
return(0);
}

LATEST TUTORIALS
APPROVED BY CLIENTS