Code:
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
char ch;
int seconds;
int minutes;
int error(void);
int main(void)
{
printf("Enter m to count down from minutes or s to countdown from seconds\n");
scanf("%c", &ch);
if(ch=='m') {
printf("Enter the amount of minutes:\n");
scanf("%d",&minutes);
for(minutes = minutes-1; minutes>-1; minutes--) {
Sleep(60000); //1 minute in milliseconds
printf("%d\n", minutes);
if(minutes==0) printf("Count Down Complete! \a \n");
}
}
else if(ch=='s') {
printf("Enter the amount of seconds:\n");
scanf("%d",&seconds);
for(seconds = seconds-1; seconds>-1; seconds--) {
Sleep(1000); //1 second in milliseconds
printf("%d\n", seconds);
if(seconds==0) printf("Count Down Complete! \a \n");
}
}
else {
error();
}
system("pause");
return 0;
}
int error(void)
{
printf("Error! press t to try again or x to exit\n\a");
scanf("%c", &ch);
if(ch=='x') {
printf("terminating program\n");
return 0;
}
else if(ch=='t') main();
else {
error();
}
} thanks guys this is along with your fixes plus an error system that i believe works a tad better and so that when you choose to count down from 8 minutes it dosnt do 9 It works perfect now thank you guys
*
sorry for double post but now that dosnt work the error function the ending process works find but the restart process does not
Bookmarks