Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <conio.h>
- int suma(int , int [] );
- void main(void)
- {
- int n, A[100], i;
- int sum=0;
- cout<<"ingrese la cantidad de casilleros de un array: "<<endl;
- cin>>n;
- for(i=1;i<=n;i++)
- {
- cout<<"ingrese el elemento del array: "<<endl;
- cin>>A[i];
- }
- suma(n,A)+A[n];
- cout<<"el resultado de la suma es: "<<suma(n,A)<<endl;
- getch();
- }
- int suma(int n, int A[])
- {
- if(n==1)
- return A[1];
- else
- return suma(n-1,A)+A[n];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement