C Program to Convert Number of Days to Years, Months & Days

#include<stdio.h>

int main()
{
    int number_of_days, years, months, days;

    /* Reading number of days from user */
    printf("Enter number of days: ");
    scanf("%d", &number_of_days);

    /* Calculating years */
    years = number_of_days / 365;

    // Calculating months
    months = (number_of_days - years *365) / 30;

    // Calculating days
    days = (number_of_days - years * 365 - months*30);

    // Displaying results
    printf("Years = %d", years);
    printf("\nMonths = %d", months);
    printf("\nDays = %d", days);

    return 0;
}

Output

Enter number of days: 3000
Years = 8
Months = 2
Days = 20

Leave a Reply

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

https://atozonlinesolutions.com/wp-content/uploads/2017/03/logo_white.png
https://atozonlinesolutions.com/wp-content/uploads/2017/03/logo_white.png
About
Products
Subscribe

If you wish to receive our latest news in your email box, just subscribe to our newsletter. We won’t spam you, we promise!

    Applauz

    As the pioneer of the lean startup movement, APPLAUZ has dedicated it’s time to sharing effective business strategies that help new businesses and enterpreneurs put their money to work in the right way.

    Subscribe

    If you wish to receive our latest news in your email box, just subscribe to our newsletter. We won’t spam you, we promise!

      Applauz

      As the pioneer of the lean startup movement, APPLAUZ has dedicated it’s time to sharing effective business strategies that help new businesses and enterpreneurs put their money to work in the right way.

      Copyright by BOLD THEMES. All rights reserved.