Source Code:
#include<iostream>
using namespace std;
int main()
{
int a[10]={0,1,2,3,4,5,6,7,8,9};
cout<<"The array elements are: ";
for(int i=0;i<10;i++)
{
cout<<a[i]<<" ";
}
cout<<endl;
cout<<"The odd elements of the array are: ";
for(int i=0;i<10;i++)
{
if(a[i]%2!=0)
{
cout<<a[i]<<" ";
}
}
return 0;
}
#include<iostream>
using namespace std;
int main()
{
int a[10]={0,1,2,3,4,5,6,7,8,9};
cout<<"The array elements are: ";
for(int i=0;i<10;i++)
{
cout<<a[i]<<" ";
}
cout<<endl;
cout<<"The odd elements of the array are: ";
for(int i=0;i<10;i++)
{
if(a[i]%2!=0)
{
cout<<a[i]<<" ";
}
}
return 0;
}
Program Output:
0 Comments