Sunday, 15 December 2013

C Program to Convert a Given Number of Days in terms of Years, Weeks & Days

#include < stdio.h>
#define DAYSINWEEK 7
 
void main()
{
    int ndays, year, week, days;
 
    printf("Enter the number of daysn");
    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 daysn",
            ndays, year, week, days);
}

Output

 Enter the number of days
 29 
 29  is equivalent to  0  years,  4  weeks and  1  days
 
   
Enter the number of days
 1000 
 1000  is equivalent to  2  years,  38  weeks and  4  days

For More Details Please Visit Ictjobs.info

No comments: