Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 3

1.

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

cout<<"Enter the size of the array :";


cin>>n;
int arr[n];
if (n>5)
{

cout<<"Enter "<<n<< " elements in an array"<<endl;


for (int i = 0; i < n; i++)
{
cin>>arr[i];
}
}
else{
cout << "Array size should be greater than 5." << endl;
return 1;
}
int newarr[n];
int count=0;
for(int i =0 ;i<n;i++){

if (arr[i] != 1 && arr[i] % 2 == 0)


{
newarr[count] = arr[i];
count++;
}
}
cout<<"Non-prime elements array"<<endl;
for(int i=0 ;i<count;i++){

cout<<newarr[i]<<" ";

}
cout << endl;

return 0;
}

2.
#include<iostream>
using namespace std;
int main(){
int Array_1[12];
cout<<"Enter 12 element :"
for(int i=0 ;i<=12;i++){
cin>>Array_1[i];
}
int count[12]=0;
for (int i = 0;i < 12; i++) {
if(Array_1[i]==count[12])

return 0;
}

3.

#include<iostream>
using namespace std;
int main(){
int n,m;

cout<<"Enter the size of the array1:";


cin>>n;
if (n<=5)
{
cout << "Array size should be greater than 5." << endl;
return 1;
}
int arr1[n];
cout<<"Enter "<<n<< " elements in an array1"<<endl;
for (int i = 0; i < n; i++)
{
cin>>arr1[i];
}
cout<<"Enter the size of the array2:";
cin>>m;
if (m<=5)
{
cout << "Array size should be greater than 5." << endl;
return 1;
}
int arr2[m];
cout<<"Enter "<<m<< " elements in an array2"<<endl;
for (int i = 0; i < m; i++)
{
cin>>arr2[i];
}
int newarr[n + m];
int count = 0;
for(int i =0 ;i<n;i++){

if (arr1[i]% 2 == 0)
{
newarr[count] = arr1[i];
count++;
}
}

for(int i =0 ;i<m;i++){

if (arr2[i]% 2 == 0)
{
newarr[count] = arr2[i];
count++;
}
}
cout<<"New even elements array :"<<endl;
for(int i=0 ;i<count;i++){

cout<<newarr[i]<<" ";

}
cout << endl;

return 0;
}

You might also like