Advertisement
salmancreation

Age in Days C program By Salman

May 21st, 2015
280
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.73 KB | None | 0 0
  1. #include<stdio.h>
  2.     int main()
  3.     {
  4.         int age,years,months,mon,mas,days;
  5.  
  6.         scanf("%d",&age);
  7.  
  8.         years = age/365;
  9.  
  10.         if( years >= 0){
  11.  
  12.             printf("%d ano(s) \n",years);
  13.         }
  14.         else{
  15.             printf("%d ano(s) \n",years);
  16.         }
  17.  
  18.         months = (years*365)/30;
  19.         mon = age-(months*30);
  20.         mas = mon/30;
  21.         if( mas <=12 ){
  22.             printf("%d mes(es)\n",mas);
  23.         }
  24.         else{
  25.             printf("%d mes(es)\n",mas);
  26.         }
  27.  
  28.         days = age-(years*365+mas*30);
  29.  
  30.         if( days >=0 ){
  31.             printf("%d dia(s)\n",days);
  32.         }
  33.         else{
  34.             printf("%d dia(s)\n",days);
  35.         }
  36.  
  37.         return 0;
  38.  
  39.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement