Program to read date,month, year and print the next day’s date,month,year - 100 Most Important C# Programs

100 Most Important C# Programs

49. Program to read date,month, year and print the next day’s date,month,year.

Code:

# include <stdio.h>

# include <conio.h>

main( )

{

int

month[12]={31,28,31,30,31,30,31,31,30,3

1,30,31};

int d,m,y,nd,nm,ny,ndays;

clrscr( );

printf(“enter the date,month,year”);

scanf(“%d%d%d”,&d,&m,&y);

ndays=month[m-1];

if(m==2)

{

if(y%100==0)

{

if(y%400==0)

ndays=29;

}

else

if(y%4==0)

ndays=29;

}

nd=nd+1;

nm=m;

ny=y;

if(nd>ndays)

{

nd=1;

nm++;

}

if(nm>12)

{

nm=1;

ny++;

}

printf(“Given date is

%d:%d:%d\n”,d,m,y);

printf(“next days date is

%d:%d:%d”,nd,nm,ny);

getch( );

}





All materials on the site are licensed Creative Commons Attribution-Sharealike 3.0 Unported CC BY-SA 3.0 & GNU Free Documentation License (GFDL)

If you are the copyright holder of any material contained on our site and intend to remove it, please contact our site administrator for approval.

© 2016-2025 All site design rights belong to S.Y.A.