• Follow Us

Convert a Given Number of Days in terms of Years/Days in C

Let’s understand how to convert a Given Number of Days in terms of Years, Weeks & Days in C Programming Language.

Convert a Given Number of Days in terms of Years

#include <stdio.h>

/*Learn C Programming at CodeAtGlance.com*/

#define WEEKDAYS 7

void main()

{

    int number_of_days, year, week, days;

    printf("Please enter the number of days\n");

    scanf("%d", &number_of_days);

    year = number_of_days / 365;

    week =(number_of_days % 365) / WEEKDAYS;

    days =(number_of_days % 365) % WEEKDAYS;

    printf ("%d is equivalent to %d years, %d weeks and %d daysn",

    number_of_days, year, week, days);

}

Leave a Reply

Your email address will not be published. Required fields are marked *

Shopping cart