C program to convert days to years weeks and days

C Programming Language / Fundamentals of C Language

2667

Program:

/**
 * C program to convert days in to years, weeks and days
 */
 
#include"stdio.h"
 
int main()
{
    int days, years, weeks;
 
    // Read total number of days from user
    printf("Enter days: ");
    scanf("%d", &days);
 
    years = (days / 365);   //Ignoring leap year
    weeks = (days % 365) / 7;
    days  = days - ((years * 365) + (weeks * 7));
 
    printf("YEARS: %d\n", years);
    printf("WEEKS: %d\n", weeks);
    printf("DAYS: %d \n", days);
 
    return 0;
} 

Output:

Enter days: 373
YEARS: 1
WEEKS: 1
DAYS: 1
Press any key to continue . . .

This Particular section is dedicated to Programs only. If you want learn more about C Programming Language. Then you can visit below links to get more depth on this subject.