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.
Extreme Recommended:- Like our Facebook Page or Join our Facebook Group and Google plus Community for up-to-date for a new post
Solution:-
#include<iostream>
using namespace std;
int main()
{
int a[100],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:-
You May Also See
1. C++ Program For Temperature Conversion Celcius To Fahrenheit And Vice Versa Using Switch Case
2. C++ Program To Find A Grade Of Given Numbers Using Switch Case
3. C++ Program To Perform All Arithnatic Operations Ie:-(a+b,a-b,a*b,a/b,a%b) Using Switch Case
4. C++ Program To Print A Reverse Order Of Any Number Using Loop
5. C++ Program Print Truth Table Of XY+Z Using Loop
6. C++ Program Convert Decimal Number To Binary Number Using Loop
7. C++ Program To Print The Fibonacci Series Up to Given Number Of Terms
8. C++ Program To Sort An Array Using BUBBLE SORT TECHNIQUE
9. C++ Program To Sort An Array Using SELECTION SORT TECHNIQUE
10. C++ Program To Merge Two Array In Third Array Unconditionally
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.
Extreme Recommended:- Like our Facebook Page or Join our Facebook Group and Google plus Community for up-to-date for a new post
Solution:-
#include<iostream>
using namespace std;
int main()
{
int a[100],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:-
You May Also See
1. C++ Program For Temperature Conversion Celcius To Fahrenheit And Vice Versa Using Switch Case
2. C++ Program To Find A Grade Of Given Numbers Using Switch Case
3. C++ Program To Perform All Arithnatic Operations Ie:-(a+b,a-b,a*b,a/b,a%b) Using Switch Case
4. C++ Program To Print A Reverse Order Of Any Number Using Loop
5. C++ Program Print Truth Table Of XY+Z Using Loop
6. C++ Program Convert Decimal Number To Binary Number Using Loop
7. C++ Program To Print The Fibonacci Series Up to Given Number Of Terms
8. C++ Program To Sort An Array Using BUBBLE SORT TECHNIQUE
9. C++ Program To Sort An Array Using SELECTION SORT TECHNIQUE
10. C++ Program To Merge Two Array In Third Array Unconditionally
0 Comments: