Convert days to years, months and days - C/C++


A basic C/C++ program which will take number of days from the user and will give the total number of years, months and days.


#include<stdio.h>
#include<conio.h>
void main()
{
 int days, day = 0, mon = 0, yer = 0;
 clrscr();
 printf("Enter Days ->");
 scanf("%d", &days);
 day = days;
 if (days > 29)
 {
  mon = days / 30;
  day = days % 30;
 }
 if (mon > 11)
 {
  yer = mon / 12;
  mon = mon % 12;
 }
 printf("\n\n%d Year  %d Month  %d Days", yer, mon, day);
 getch();
}

Post a Comment