nikolas_serafini

Lista 2 - Exercício 28

May 26th, 2013
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.82 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main()
  5. {
  6.        
  7.     int day,month,year,currday,currmo,curryea,lifey,lifem,lifed,totald;
  8.  
  9.     printf("Entre com a sua data de nascimento : (formato dd/mm/aaaa)\n");
  10.     scanf("%d %d %d",&day,&month,&year);
  11.     printf("Entre com a data autal : (formato dd/mm/aaaa)\n");
  12.     scanf("%d %d %d",&currday,&currmo,&curryea);
  13.  
  14.     totald = (curryea*365 + currmo*30 + currday) - (year*365 + month*30 + day);
  15.     lifey = totald/365;
  16.     lifem = (totald%365)/30;
  17.     lifed = totald - (lifey*365 + lifem*30);
  18.  
  19.     printf("Voce possui %d anos, %d meses e %d dias de vida.\n",lifey,lifem,lifed);
  20.     if (lifey>=16)
  21.     {
  22.             printf("Voce ja pode votar!\n");
  23.     }    
  24.     if ((lifey)>=18)
  25.     {
  26.         printf("Voce ja pode tirar a habilitacao!\n");
  27.     }
  28.     return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment