Convert Days to years, weeks and days.

SemiColon
By -
0
4. Write a C program to input number of days from user and convert it to years, weeks and days. 

Example:

Input
Enter days: 373

Output
373 days = 1 year/s, 1 week/s and 1 day/s




Solution:


#include<stdio.h>
int main()
{
    int a,Day,Weeks,Year;

    printf("Enter days:");
    scanf("%d",&a);

    Year=a / 365;
    Weeks=(a % 365 )/ 7;
    Day=a % 365 % 7;

    printf("%d days = %d year/s, %d week/s and %d day/s",a, Year, Weeks, Day);

    return 0;

}

Tags:

Post a Comment

0Comments

Post a Comment (0)