So I have to build a program that is timer in the format of h:m:s. It's based off a martian time scale. This is what I have, but the program will do some wierd thing at the beggning where it like shows the minutes, but then loses them and just counts the seconds over and over. Plus i need to put in a reminder at certain times, and thats not showing up.
Code:
#include <stdio.h>
#define HOURS 20
#define MINS 12
#define SECS 15
int main() {
int choice=0;
int fchoice;
int hours,mins, secs;
int th, tm, ts;
int done=0;
hours=0;
mins=0;
secs=0;
while (choice != 3) {
//Choice
printf("Choose one of the following menu options\n");
printf("1: set time\n");
printf("2: start timer\n");
printf("3: quit\n");
scanf("%d", &choice);
//Converstions
// Execute option 1.
if (choice == 1) {
printf("Enter in the time.\n");
scanf("%d:%d:%d", &hours, &mins, &secs);
}
// Execute option 2.
else if (choice == 2) {
printf("How long would you like me to count?\n");
scanf("%d:%d:%d", &th, &tm, &ts);
hours+=HOURS;
mins+=MINS;
secs+=SECS;
while (done!=1){
for (hours=hours-HOURS;((hours<HOURS)&&(done!=1));hours++)
for (mins=mins-MINS;((mins<MINS)&&(done!=1)); mins++)
for (secs=secs-SECS;((secs<SECS)&&(done!=1)); secs++)
{
printf("current time > %d:%d:%d\n", hours,mins,secs);
printf("current timer > %d:%d:%d\n", th,tm,ts);
if ((hours=4)&&(mins=0)&&(secs=0)){
printf("Have you had your breakfast?\n");
printf("1: Yes\n");
printf("0: No\n");
scanf("%d", &fchoice);
}
if ((th==0)&&(tm==0)&&(ts==0)){
done=1;
}
ts--;
if (ts==-1){
ts=SECS-1;
if(tm==-1){
tm=MINS-1;
if(th==-1){
th=HOURS-1;}
else
th--;
}
else
tm--;
}
}
}
hours=0;
mins=0;
secs=0;
}
else if (choice == 3) {
printf("Thankyou.\n");
break;
}
else
printf("invalid answer, try again.\n");
}
return 0;
}