This program will count the number of Years,weeks and days in total number of days entered by user.Let us see an example.Suppose User there are 374 days total then we can say that 374 days is equal to "1 year 1 week and 2 days". This program does same thing.Now let us see program:
Program:
#include<stdio.h>
#include<conio.h>
main()
{
long days,years,n,weeks,months;
clrscr();
printf("Enter number of days: ");
scanf("%ld",&n);
years=n/365;
n=n%365;
weeks=n/7;
n=n%7;
days=n;
printf("\n%ld Year(s) ",years);
printf("%ld week(s) ",weeks);
printf("%ld day(s)",days);
getch();
}
output:
Program:
#include<stdio.h>
#include<conio.h>
main()
{
long days,years,n,weeks,months;
clrscr();
printf("Enter number of days: ");
scanf("%ld",&n);
years=n/365;
n=n%365;
weeks=n/7;
n=n%7;
days=n;
printf("\n%ld Year(s) ",years);
printf("%ld week(s) ",weeks);
printf("%ld day(s)",days);
getch();
}
output: