Advertisement
heian

Untitled

Oct 24th, 2019
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. /**
  6. Sa se scrie un subprogram cu numele produs care are ca parametru un vector
  7. si numarul de elemente din acel vector, si returneaza produsul elementelor
  8. de pe pozitii impare.
  9. */
  10.  
  11.  
  12. int produs(int v[],int n)
  13. {
  14. int p=1,i;
  15. for(i=1;i<=n;i=i+2)
  16. p=p*v[i];
  17. return p;
  18. }
  19.  
  20.  
  21. int main()
  22. {
  23. int n,v[10001];
  24. cin>>n;
  25. for(i=1;i<=n;i++)
  26. cin>>v[i];
  27. cout<<produs(v,n)<<"\n";
  28. return 0;
  29.  
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement