WAP in C to Convert a Given Number of Days in terms of Years, Weeks & Days(ignore leap year)?

#include<stdio.h>
#include<conio.h>
#define DAYSINWEEK 7

int main()
{
int numdays, year, week, days;
clrscr();
printf(“Enter the number of days”);
scanf(“%d”, &numdays);
year = numdays / 365;
week =(numdays % 365) / DAYSINWEEK;
days =(numdays % 365) % DAYSINWEEK;
printf (“%d is equivalent to %d years, %d weeks and %d days”,numdays, year, week, days);
getch();
return(0);
}

Output :-

convertdaytoweek.png

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s