IvoSilva

[PROG1] Ficha 6 | Exercício 2

Nov 20th, 2011
340
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.42 KB | None | 0 0
  1. #include <stdio.h>
  2. int resto (int num1 , int num2 )
  3. {
  4.     while (num1 >= num2) num1 -= num2 ;
  5.     return (num1) ;
  6. }
  7. int par (int num)
  8. {
  9.     if (!resto(num , 2)) return 1 ;
  10.     else return 0 ;
  11. }
  12. int main ()
  13. {
  14.     int num ;
  15.     printf ("Insira um número: ") ;
  16.     scanf ("%d" , &num) ;
  17.     if (par(num)) printf ("O número %d é par.\n" , num) ;
  18.     else printf ("O número %d é ímpar.\n" , num) ;
  19.     return 0 ;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment