Input month number and print number of days in that month
Sample Output
Enter month number(1 - 12): 2 Month number 2 2 for February. (28 or 29 days) Process returned 0 (0x0) execution time : 5.216 s Press any key to continue.
Source Code
#include<stdio.h>
int main()
{
char num;
printf("Enter month number(1 - 12): ");
scanf("%d", &num);
if(num == 1)
{
printf("\nMonth number %d\n\n%d for January. (31 days)\n", num, num);
}
else if(num == 2)
{
printf("\nMonth number %d\n\n%d for February. (28 or 29 days)\n", num, num);
}
else if(num == 3)
{
printf("\nMonth number %d\n\n%d for March. (31 days)\n", num, num);
}
else if(num == 4)
{
printf("\nMonth number %d\n\n%d for April. (30 days)\n", num, num);
}
else if(num == 5)
{
printf("\nMonth number %d\n\n%d for May. (31 days)\n", num, num);
}
else if(num == 6)
{
printf("\nMonth number %d\n\n%d for June. (30 days)\n", num, num);
}
else if(num == 7)
{
printf("\nMonth number %d\n\n%d for July. (31 days)\n", num, num);
}
else if(num == 8)
{
printf("\nMonth number %d\n\n%d for August. (31 days)\n", num, num);
}
else if(num == 9)
{
printf("\nMonth number %d\n\n%d for September. (30 days)\n", num, num);
}
else if(num == 10)
{
printf("\nMonth number %d\n\n%d for October. (31 days)\n", num, num);
}
else if(num == 11)
{
printf("\nMonth number %d\n\n%d for November. (30 days)\n", num, num);
}
else if(num == 12)
{
printf("\nMonth number %d\n\n%d for December. (31 days)\n", num, num);
}
else
{
printf("\nInvalid Month number!\n");
}
return 0;
}
Sample Output
Enter month number(1 - 12): 3 Month number 3 3 for March. (31 days) Process returned 0 (0x0) execution time : 2.333 s Press any key to continue.
No comments:
Post a Comment