Advertisement
Waliul

Solution of 2

Mar 16th, 2021
1,010
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.51 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int EvenCount(int *arr, int n)
  5. {
  6.     int i, cnt = 0;
  7.     for(i = 0; i < n; i++)
  8.     {
  9.         if((*arr) % 2 == 0)
  10.             cnt++;
  11.         arr++;
  12.     }
  13.     return cnt;
  14. }
  15.  
  16. int main()
  17. {
  18.     int i, j, k, sz, n;
  19.     cout<<"Enter the size of the array : ";
  20.     cin>>n;
  21.     int arr[n];
  22.     cout<<"Enter the elements : ";
  23.     for(i = 0; i < n; i++)
  24.         cin>>arr[i];
  25.     cout<<"The number of even numbers in the array : "<<EvenCount(arr, n)<<endl;
  26. }
  27.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement