Input month number and print the number of days in that month with C language
#include <stdio.h>
int main()
{
int monthNum;
printf("Enter monthNum number (1-12): ");
scanf("%d", &monthNum);
if (monthNum == 1)
{
printf("31 days");
}
else if (monthNum == 2)
{
printf("28 or 29 days");
}
else if (monthNum == 3)
{
printf("31 days");
}
else if (monthNum == 4)
{
printf("30 days");
}
else if (monthNum == 5)
{
printf("31 days");
}
else if (monthNum == 6)
{
printf("30 days");
}
else if (monthNum == 7)
{
printf("31 days");
}
else if (monthNum == 8)
{
printf("31 days");
}
else if (monthNum == 9)
{
printf("30 days");
}
else if (monthNum == 10)
{
printf("31 days");
}
else if (monthNum == 11)
{
printf("30 days");
}
else if (monthNum == 12)
{
printf("31 days");
}
else
{
printf(" monthNum valid !");
}
return 0;
}
Output:-
Enter monthNum number(1 - 12) : 5
31 days
0 Comments