#includevoid main(){ int n; int y,m,d; printf("enter a number "); scanf("%d",&n); printf(" "); if (n/365 > 0) { printf("%d Year(s),",n/365); n=n%365; } if (n/30 >0) { printf("%2d Month(s),",n/30); n=n%30; } if (n/7 >0) { printf("%3d week(s),",n/7); n=n%7; } if (n>0) { printf("%3d Day(s)",n); }}OutPut:enter a number9 0 3 Month(s)
Please Note: We keep on updating better answers to this site. Subscribe to our newsletter to get notified when better answer is posted.
Copyright ©2003-2009 CoolInterview.com, All Rights Reserved. Privacy Policy | Terms and Conditions Page URL: http://www.coolinterview.com/interview/6089/default.asp?cachecommand=bypass