FedericoGB25
Coder
Hello guys
I am new in this Forum and programming. I have a problem with my C "program":
I am trying to make a program where user can insert the current date. But at the final result, my output is this:
My code:
Thanks for help
I am new in this Forum and programming. I have a problem with my C "program":
I am trying to make a program where user can insert the current date. But at the final result, my output is this:
Code:
** Data corrente **
Type the current day:
5
Type the current month:
10
Type the current year:
2019
Current date:
*Day: 5
*Month: 4
*Year: 2019
My code:
C:
#include <stdio.h>
int main() {
int day, month, year;
printf("** Current date **\n");
printf("\nType the current day:\n");
scanf("%d", &day);
if(day>31) {
printf("Invalid day");
return 0;
}
printf("\nType the current month:\n");
scanf("%d", &month);
if(month>12) {
printf("Invalid month");
return 0;
}
if(month=2 && day>29) {
printf("Invalid month");
return 0;
}
if(month=4,6,9,11 && day>=31) {
printf("Invalid month");
return 0;
}
printf("\nType the current year\n");
scanf("%d", &year);
printf("\nCurrent date:\n *Day: %d\n *Month: %d\n *Year: %d\n", day, month, year);
}
Thanks for help
Last edited: