Q:

Write a C program to convert specified days into years, weeks and days

0

Write a C program to convert specified days into years, weeks and days.

Note: Ignore leap year.

Test Data :
Number of days : 1329
Expected Output :
Years: 3
Weeks: 33
Days: 3

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

#include <stdio.h> 
int main()
{
    int days, years, weeks;
    days = 1329; 
    // Converts days to years, weeks and days
    years = days/365; 
    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;
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

C Basic Declarations and Expressions exercises

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
Write a C program that accepts two integers from t... >>
<< Write a C program to display multiple variables...