by CodeChum Admin
I have an array of 3 numbers here with me that's already in the code editor, but I want you to add some more to this list by inputting some more numbers yourself in one line and then, print out only the even numbers from the array.
Can you do that for me?
Input
The first line contains the number of elements, n, to be added.
The next line contains the n integers separated by a space.
5
33·54·32·11·8
Output
Multiple lines containing an integer.
2
54
32
8
#include<conio.h>
#include<stdio.h>
#include<stdlib.h>
#include <iostream>
using namespace std;
int main()
{
int Count;
cout<<"\n\tEnter Count of Numbers: "; cin>>Count;
int Nums[Count],n=0;
for(n=0;n<Count;n++)
{
cout<<"\n\tEnter Number-"<<n+1<<": "; cin>>Nums[n];
}
cout<<"\n\tEven Numbers:";
for(n=0;n<Count;n++)
{
if(Nums[n]%2==0) cout<<"\n\t"<<Nums[n];
}
return(0);
}
Comments
Leave a comment