#include<stdio.h>
#include<conio.h>
void main()
{
int month_no;
printf("Enter the month number (1-12): ");
scanf("%d",&month_no);
if(month_no==1 || month_no==3 || month_no==5 || month_no==7 ||
month_no==8 || month_no==10 || month_no==12)
printf("\nThis month has 31 days");
else if(month_no==4 || month_no==6 || month_no==9 || month_no==11)
printf("\nThis month has 30 days");
else if(month_no==2)
printf("\nThis month has 28 days\nIn leap year it has 29 days");
else
printf("\nPlease enter a valid month number between 1 and 12");
getch();
}
Output:
#include<conio.h>
void main()
{
int month_no;
printf("Enter the month number (1-12): ");
scanf("%d",&month_no);
if(month_no==1 || month_no==3 || month_no==5 || month_no==7 ||
month_no==8 || month_no==10 || month_no==12)
printf("\nThis month has 31 days");
else if(month_no==4 || month_no==6 || month_no==9 || month_no==11)
printf("\nThis month has 30 days");
else if(month_no==2)
printf("\nThis month has 28 days\nIn leap year it has 29 days");
else
printf("\nPlease enter a valid month number between 1 and 12");
getch();
}
Output:
Please have a look at the below lesson posted on my YouTube channel:
No comments:
Post a Comment