Advertisement
Tahamina_Taha

convert Days to Remaining Year, Month, Week and Days

Jul 10th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.48 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<math.h>
  3. int main(void)
  4.  
  5. {
  6.     int days,weeks,years,months;
  7.     printf("Enter days: ");
  8.     scanf("%d",&days);
  9.     years=days/365;
  10.         //1 year=365 days
  11.     months=(days-(years*365))/30;
  12.         //1 month=30 days
  13.     weeks=(days-(years*365))/7;
  14.         //1 week =7 days
  15.     days=days-((years*365)+(weeks*7));
  16.     printf("Years: %d\n",years);
  17.     printf("Months: %d\n",months);
  18.     printf("Weeks: %d\n",weeks);
  19.     printf("Days: %d\n",days);
  20.  
  21.  
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement