Hi everyone!
This is the code that I have made, however, when I enter a date for example if I type : 12/12/2012 then the date for tomorrow displays a list of dates. I am unsure how to get it to only display the date of tomorrow.
include <stdio.h>
int main (int argc, char *argv[]) {
int dd;
int mm;
int yyyy;
int n = 3;
printf("Enter date in format dd/mm/yyyy: \n");
n = scanf("%d/%d/%d", &dd, &mm, &yyyy);
printf("Date read: %d/%d/%d\n", dd, mm, yyyy);
if (n==3) {
if (dd==31 && mm==1) {
printf("Tomorrow: 01/02/%d\n", yyyy);
}
else if (dd==28 && mm==2 && yyyy%4==0) {
printf("Tomorrow: 29/02/%d\n", yyyy);
}
else if (dd==29 && mm==2 && yyyy%4==0) {
printf("Tomorrow: 01/03/%d\n", yyyy);
}
else if (dd==28 && mm==2 && yyyy%4!=0) {
printf("Tomorrow: 01/03/%d\n", yyyy);
}
else if (dd==31 && mm==3) {
printf("Tomorrow: 01/04/%d\n", yyyy);
}
else if (dd==30 && mm==4) {
printf("Tomorrow: 01/05/%d\n", yyyy);
}
else if (dd==31 && mm==5) {
printf("Tomorrow: 01/06/%d\n", yyyy);
}
else if (dd==30 && mm==6) {
printf("Tomorrow: 01/07/%d\n", yyyy);
}
else if (dd==31 && mm==7) {
printf("Tomorrow: 01/08/%d\n", yyyy);
}
else if (dd==31 && mm==8) {
printf("Tomorrow: 01/09/%d\n", yyyy);
}
else if (dd==30 && mm==9) {
printf("Tomorrow: 01/10/%d\n", yyyy);
}
else if (dd==31 && mm==10) {
printf("Tomorrow: 01/11/%d\n", yyyy);
}
else if (dd==30 && mm==11) {
printf("Tomorrow: 01/12/%d\n", yyyy);
}
else if (dd==31 && mm==12) {
yyyy = yyyy + 1;
printf("Tomorrow: 01/01/%d\n", yyyy);
}
//30 day months
else if (dd>0 && dd<30 && (mm==4 || mm==6 || mm==9 || mm==11)) {
(dd = dd + 1); {
printf("Tomorrow: %d/%d/%d\n", dd, mm, yyyy);
}
}
//31 day months
else if (dd>0 && dd<31 && (mm==1 || mm==2 || mm==5 || mm==7 || mm==8 || mm==10 || mm==12)) {
(dd = dd + 1); {
printf("Tomorrow: %d/%d/%d\n", dd, mm, yyyy);
} }
}
else if (n!=3) {
return 0;
}
return 0;
}
Thank you for any help you can offer