Advertisement
Dizzy3113

Untitled

Nov 3rd, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.25 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. int P(int a[100], int n)
  5. {
  6. int s=0;
  7. for(int i=0; i<n; i++)
  8. if(a[i]%2==1)
  9. s=s+a[i];
  10. return s;
  11. }
  12. int main()
  13. {
  14. int a[100]={3, 2, 7, 1, 4, 3};
  15.  
  16. cout<<P(a, 6);
  17.  
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement