Thursday 26 January 2012

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

#include<stdio.h>
#include<conio.h>
#include<dos.h>
void 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();
}

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 

No comments:

Post a Comment