9. Write a C program to convert specified days into years, weeks and days.
/*
9. 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
*/
#include<stdio.h>
main(void)
{
int number_of_days=1329;
int years=number_of_days/365;
int weeks=(number_of_days%365)/7;
int days = number_of_days- ((years*365) + (weeks*7));
printf("Years:%d\n",years);
printf("Weeks:%d\n",weeks);
printf("Days:%d\n",days);
}
Comments
Post a Comment
PLEASE DO NOT ENTER THE SPAM LINK IN THE COMMENT BOX