0% found this document useful (0 votes)
53 views

#Include Void Int

The document contains a C program that takes a date, month, and year as input from the user. It then checks if the date is valid and increments the date to the next valid date, printing the result. It handles incrementing the date, month, and year appropriately for different months, years, and date ranges.

Uploaded by

ChandrikaGowda
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
53 views

#Include Void Int

The document contains a C program that takes a date, month, and year as input from the user. It then checks if the date is valid and increments the date to the next valid date, printing the result. It handles incrementing the date, month, and year appropriately for different months, years, and date ranges.

Uploaded by

ChandrikaGowda
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

#include<stdio.

h>
void main()
{
int date,month,year;
printf("Enter date month year\n");
scanf("%d %d %d",&date,&month,&year);
if(year>1812 && year<2014)
{
if(month==2)
{
if(year%4==0)
{
if(date==29)
{
month=month+1;
date=1;
}
else if(date<29)
{
date=date+1;
}
}
else if(date==28)
{
month=month+1;
date=1;
}
else if(date<28)
{
date=date+1;
}
}
else if(month==12)
{
if(date==31)
{
month=1;
date=1;
year=year++;

}
else if(date<31)
{
date=date+1;
}
}
else if(month==1 || month==3 ||month==5 || month==7
||month==8 ||month==10)
{
if(date==31)
{
month=month+1;
date=1;
}
else if(date<31)
{
date=date+1;
}
}
else if(month==4 || month==6 || month==9 || month==11)
{
if(date==30)
{
month=month+1;
date=1;
}
else if(date<30)
{
date=date+1;
}
}
printf("The next date is %d:%d:%d\n",date,month,year);
}
else
{
printf("Invalid date\n");
}
}

You might also like