100 Most Important C Programs by Aditya Shakkarwar

100 Most Important C Programs by Aditya Shakkarwar

Author:Aditya Shakkarwar [Shakkarwar, Aditya]
Language: eng
Format: epub
Published: 2015-02-20T18:30:00+00:00


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( );

}



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.