c - Accept days & convert it into equivalent no. of years, months, weeks & remaining days -



c - Accept days & convert it into equivalent no. of years, months, weeks & remaining days -

i trying solve on how create these formulas right on c programming. these few lines of code.

my programme supposed input user day , give equiv. in years,months,weeks, , days.

so illustration have 730 days. if im going convert in years months, weeks... there 2 years, o months, 0, weeks, , 0 days (not sure if right). example, have 402 days there 1 year, 1 month, 1 week, 0 days left(am right?).

the code had "month" before month =(days /365)/30; , changed month =(days %365)/30;

last time when inputted number, answers right when entered different numbers, seems wrong.

#include<stdio.h> #include<conio.h> void main( ) { int days ,yr,mn,wk,d; printf("enter no of days"); scanf("%d",&days); yr = days /365; mn =(days /365)/30; printf("years= %d \t months= %d \t weeks =%d \t days = %d",yr,mn,wk,d); getch(); }

so having hard time solving right formula. hope can little help on wrong formula not getting right outputs. must utilize mod this.

the key is: each successively smaller unit of time, need working number of days left over have accounted for. in illustration of 50 days, there no years, , 1 month; 1 time you've accounted month, there still 50-30=20 days left business relationship for.

so algorithm be: each successively smaller unit of time, compute how many of unit there are, , subtract out number of days covered (leaving days left business relationship for).

c converter formula modulo

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -