Subscribe

RSS Feed (xml)

Saturday, October 3, 2009

Write a C program to display the System date and Change the system date if necessary.

#include(stdio.h) // note use '<' & '>' in place of '(' & ')'
#include(conio.h)
#include(dos.h)
int main( )
{
int dd, mm, yy;
struct date s;
clrscr( );
getdate(&s);
printf("Present System Date ( dd/mm/yy ):-- %d / %d / %d ", s.da_day, s.da_mon, s.da_year);
printf("\nEnter the new date ( dd/mm/yy) :");
scanf("%d%d%d", &dd, &mm, &yy);
s.da_day=dd;
s.da_mon=mm;
s.da_year=yy;
setdate(&s);
printf("\n After changing, Present date (dd/mm/yy): %d / %d / %d", s.da_day, s.da_mon, s.da_year);
getch( );
return 0;
}

Output:- Present System Date ( dd/mm/yy): 04/10/2009
Enter the new date (dd/mm/yy): 10
10
2009
After Changing, Present date (dd/mm/yy): 10/10/2009

1 comment: