(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.
1
Expert's answer
2012-09-06T10:04:40-0400
#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; }
Comments
Leave a comment