-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharrayoddeven.cpp
More file actions
40 lines (36 loc) · 1.04 KB
/
Copy patharrayoddeven.cpp
File metadata and controls
40 lines (36 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
//Program to enter numbers using array and display odd and even numbers from list separately.
#include <iostream>
using namespace std;
int main()
{
int array[100], i, num,even=0,odd=0;
cout<<"Enter the size of an array \n";
cin>>num;
cout<<"Enter the elements of the array \n";
for (i = 0; i < num; i++)
{
cin>>array[i];
}
cout<<"Even numbers in the array are : ";
for (i = 0; i < num; i++)
{
if (array[i] % 2 == 0)
{
even++;
cout<<endl;
cout<<array[i];
}
}
cout<<"\nOdd numbers in the array are: ";
for (i = 0; i < num; i++)
{
if (array[i] % 2 != 0)
{
odd++;
cout<<endl;
cout<<array[i];
}
}
cout<<"\nThere are "<<even<<" numbers and "<<odd<<" odd numbers out "<<num<<" given numbers.";
return 0;
}