Advertisement
Ciro_meneses

Imprime Numeros Pares Recursivo.c

Apr 7th, 2015
275
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.36 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. void imprime_pares(int n);
  6.  
  7. int main() {
  8.   int numero = 0;
  9.  
  10.   printf("Digite o numero: ");
  11.   scanf("%d", &numero);
  12.  
  13.   imprime_pares(numero);
  14.  
  15.   return 0;
  16. }
  17.  
  18. void imprime_pares(int n) {
  19.  
  20.   if(n < 2)
  21.     exit(1);
  22.   else if (n % 2 == 0)
  23.     printf("%d-", n);
  24.  
  25.   imprime_pares(n-1);
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement