Task: Count and Sum of Even Numbers in Array C++ Program

### The Source Code of Count and Sum of Even Numbers in Array

// Write a C++ program to input 10 numbers // in array then display even numbers, their // sum and count in array // Author: www.EasyCodeBook.com (c) #include<iostream> using namespace std; int main() { int arr[10],i,sum,count; for(i=0;i<10;i++) { cout<<"Enter Number "<<(i+1)<<" :"; cin>>arr[i]; } sum=count=0; cout<<"Even numbers in Array are:"<<endl; for (i=0;i<10;i++) if(arr[i]%2==0) { cout<<arr[i]<<", "; count++; sum=sum+arr[i]; } cout<<"\nCount of Even numbers is: "<<count<<endl; cout<<"Sum of Even numbers is: "<<sum<<endl; return 0; }

### The output of C++ Array Program

Enter Number 1 :1 Enter Number 2 :2 Enter Number 3 :6 Enter Number 4 :8 Enter Number 5 :4 Enter Number 6 :2 Enter Number 7 :8 Enter Number 8 :12 Enter Number 9 :16 Enter Number 10 :20 Even numbers in Array are: 2, 6, 8, 4, 2, 8, 12, 16, 20, Count of Even numbers is: 9 Sum of Even numbers is: 78 -------------------------------- Process exited after 24.26 seconds with return value 0 Press any key to continue . . .

Pingback: Array Sum & Count Odd Numbers C Plus Plus | EasyCodeBook.com

Pingback: Sum & Count of Even Odd Separately in Array | EasyCodeBook.com