C program to convert days into years, weeks and days
/**
*To convert days in to years, weeks and days
*/
#include <stdio.h>
main()
{
int days, years, weeks;
/* Input total number of days from user */
printf("Enter days: ");
scanf("%d", &days);
/* Conversion */
years = (days / 365); // Ignoring leap year
weeks = (days % 365) / 7;
days = (days%365)%7;
/* Print all resultant values */
printf("YEARS: %d\n", years);
printf("WEEKS: %d\n", weeks);
printf("DAYS: %d", days);
}
OUT PUT
Enter days: 365
YEARS: 1
WEEKS: 0
DAYS: 0
--------------------------------
Related Question
*********************************************


0 Comments