C Program to convert days into years, weeks and days
C Program to convert days to years,
weeks and days
Write a C Program to convert given number of days to a measure
of time given in years, weeks and days. For example 375 days is equal to 1 year
1 week and 3 days (ignore leap year).Read more about
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
/***********************************************************
* You can use all the programs on
www.c-program-example.com
* for personal and learning purposes. For permissions to
use the
* programs for commercial purposes,
* contact info@c-program-example.com
* To find more C programs, do visit
www.c-program-example.com
* and browse!
*
*
Happy Coding
***********************************************************/
#include <stdio.h>
#define DAYSINWEEK 7
void main()
{
int ndays, year, week, days;
printf("Enter the number of days\n");
scanf("%d",&ndays);
year = ndays/365;
week = (ndays % 365)/DAYSINWEEK;
days = (ndays%365) % DAYSINWEEK;
printf
("%d is equivalent to %d years, %d weeks and %d
days\n",
ndays, year, week, days);
}
|
Comments
Post a Comment