nikolas_serafini

Lista 1 - Exercício 4

May 21st, 2013
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.41 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main()
  5. {
  6.     int currentyear,birthyear,age;
  7.  
  8.     printf("Entre com o ano de seu nascimento:\n"); scanf("%d",&birthyear);
  9.     printf("Entre com o ano atual:\n"); scanf("%d",&currentyear);
  10.  
  11.     age = currentyear - birthyear;
  12.    
  13.     if(age<0)
  14.     {
  15.         printf("ERRO : Ano atual antecede nascimento!\n");
  16.         return 0;
  17.     }
  18.    
  19.     printf("Voce tem %d ano(s) de idade!\n",age);
  20.     return 0;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment