C Program To Know No of days in a Given Month

#include<stdio.h>
#include<conio.h>
main()
{
int month;
printf("Enter month number (1-12) to know the no.of days: ");
scanf("%d",&month);
switch(month)
{
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12: printf("...%d month has 31 days...",month);
  break;
case 2:printf("...%d month has 28 days (29 if it is leap year)");
 break;
case 4:
case 6:
case 9:
case 11: printf("...%d month has 30 days...",month);
 break;
default: printf("Sorry...!! Wrong option entered...");
}
getch();
}
Bhanu Namikaze

Bhanu Namikaze is an Ethical Hacker, Security Analyst, Blogger, Web Developer and a Mechanical Engineer. He Enjoys writing articles, Blogging, Debugging Errors and Capture the Flags. Enjoy Learning; There is Nothing Like Absolute Defeat - Try and try until you Succeed.

No comments:

Post a Comment