Completely Solved C, C++ Programs Assignment.




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

Filed Under:

Problem 49. C Program to read date,month, year and print the next day’s date,month,year.
#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:%dn”,d,m,y);
printf(“next days date is
%d:%d:%d”,nd,nm,ny);
getch( );
}
C compiler: gcc 4.1.2

 Back to main directory: Sample C Program | Software Practical | Solved C Assignment


Get Free Programming Tutorials and Solved assignments