Saturday, 22 August 2015

Write a C Program to print year, month and remaining days.



#include<stdio.h>
#include<conio.h>

int main()
{

int day,y,m; /*day for day input & output,
y for calculate year,
m for calculate month
           
printf("Enter the number of days : ");
            scanf("%d",&day);
           
y=day/365;    //calculate years
            day%=365;   // calculate remaining days
           
m=day/30;    // calculate months
            day%=30;    // calculate remaining days
           
printf("%d years,%d months, %d days",y,m,day);
           
getch();
           
return 0;


}

No comments:

Post a Comment