# C++ Program To Check Evenness And Oddness In An Array

Problem:- Program To Check Each Element of a 1-D Integer Array For Evenness / Oddness. Means you have to find even and odd number in an array.

Check This:- Hacker rank solution for Strings, Classes, STL, Inheritance in C++.

Explanation:- If the number is divided by 2 then the number is an even number if not the number is odd. So we divide the number of an array one by one of an array if number divide by 2 and reminder is zero then the number is even and if the remainder is not zero then the number is odd. Check here C++ Program To Find Number Is Even Or Odd Using Pointer then proceed for an array.

Solution:-

#include<iostream>
using namespace std;
int main()
{
int a,i,n,sum=0;

cout<<"Enter The Size of Array\n";
cin>>n;

cout<<"Enter The Element\n";
for(i=0;i<n;i++)
{
cin>>a[i];
}
cout<<"Elment in Array is Given Below\n";
for(i=0;i<n;i++)
{
if(i%2==0)
cout<<"Evenness  \n"<<a[i]<<"  ";
else
cout<<"Oddness  \n"<<a[i]<<"  ";
}
return 0;

}

Output:-

Previous Post
Next Post

#### post written by: Ghanendra Yadav

Hi, I’m Ghanendra Yadav, SEO Expert, Professional Blogger, Programmer, and UI Developer. Get a Solution of More Than 500+ Programming Problems, and Practice All Programs in C, C++, and Java Languages. Get a Competitive Website Solution also Ie. Hackerrank Solutions and Geeksforgeeks Solutions. If You Are Interested to Learn a C Programming Language and You Don't Have Experience in Any Programming, You Should Start with a C Programming Language, Read: List of Format Specifiers in C.