Program to display no. of days in entered month

//Program to display no. of days in entered month
#include<stdio.h>
#include<conio.h>
int main()
{
int m,y,d;
clrscr();
printf("Enter Month number and Year");
scanf("%d%d",&m,&y);


    if(m==1||m==3||m==5||m==7||m==8||m==10||m==12)
    {
    if(y%4==0&&y%100!=0||y%400==0)
         printf("Month days=31, Year days=366");
    else printf("Month days=31, Year days=365");

    }

    if(m==2)
    {
    if(y%4==0&&y%100!=0||y%400==0)
       printf("Month days=29, Year days=366");
    else printf("Month days=28, Year days=365");
    }

    if(m==4||m==6||m==9||m==11)
    {
    if(y%4==0&&y%100!=0||y%400==0)
    printf("Month days=30, Year days=366");
    else printf("Month days=30, Year days=365");
    }
getch();
return 0;     //Return successfuly to calling area

}

To Run this Program Copy it in text editor and save as .c
Then double click on it and then it will get opened in your compiler.
Click on run.

No comments:

Post a Comment