Contact Learn C
Copy Program Share Program

Program 15:To convert given days to years,week and days

Program 15:
 
#include<stdio.h>
 main()
 {
 int nodays,years,weeks,days;
 printf("Enter the total days\n");
 scanf("%d",&nodays);
 years=nodays/365;
 weeks=(nodays%365)/7;
 days=(nodays%365)%7;
 printf("%d = %d years,%d weeks,%d days\n",nodays,years,weeks,days);
}
Explanation:
  1. Initialized
    • nodays-number of days for input from user
    • years - to store number of years which is obtained by dividing number of days by 365.
    • weeks- to store number of weeks
    • days- to store number of days.
  2. Remaining is self explanatory.
Output:

Convert given days to years,week and days

Download App and Learn when ever you want

Get it on PlayStore
Get it on Amazon App Store
Get it on Aptoide