Advertisement
gonzalob

Untitled

Nov 9th, 2021
660
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.75 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main()
  5. {
  6.     int arreglo[10] = {10,20,30,40,50,60,70,80,90,100};
  7.     mostrarArreglo2(arreglo,10,0);
  8.     return 0;
  9. }
  10.  
  11.  
  12. int suma (int a, int b)
  13. {
  14.     int c = a + b;
  15.     return c;
  16. }
  17.  
  18. //llamado recursivo
  19. //condicion de corte
  20. //acercamiento a la condicion de corte
  21. //NO podemos poner WHILE O FOR
  22.  
  23. void mostrarArreglo(int arreglo[10],int DIM,int pos)
  24. {
  25.     if (pos < DIM)
  26.     {
  27.         printf("estamos en la posicion %d\n",pos);
  28.         printf("A: %d\n",arreglo[pos]);
  29.         mostrarArreglo(arreglo,DIM,pos+1);
  30.     }
  31. }
  32.  
  33. void mostrarArreglo2(int arreglo[10],int DIM,int pos)
  34. {
  35.     if (pos < DIM)
  36.     {
  37.         mostrarArreglo2(arreglo,DIM,pos+1);
  38.         printf("A: %d\n",arreglo[pos]);
  39.     }
  40. }
  41.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement