You are on page 1of 2

Q no 1

#include<iostream>
using namespace std;
void main()
{
int Array[25]={0};
int num=0;
cout<<"Please Enter the 25 Numbers Integer Array"<<endl;
for(int i=0;i<25;i++)
{
cin>>Array[i];
}
for(i=0;i<25;i++)
{
for(int x=0;x<25;x++)
{
if(Array[i]+Array[x]==25)
{
cout<<Array[i]<<"+"<<Array[x]<<" = "<<"25"<<endl
;
}
else
{
if(Array[i]+Array[x]+Array[x+1]==25)
{
cout<<Array[i]<<"+"<<Array[x]<<" + "<<Ar
ray[x+1]<<" = "<<"25"<<endl;
}
}
}
}
cout<<"EVEN And ODD Numbers"<<endl<<endl;
for(i=0;i<25;i++)
{
if(Array[i]%2==0)
{
cout<<endl;
cout<<Array[i]<<" -------> Even Number"<<endl;
}
else
{
cout<<endl;
cout<<Array[i]<<" -------> Odd Number"<<endl;
}
}
}
----------------------------------------------------------------------------------------Q no 2
#include<iostream>
#include<string>
using namespace std;
void main()
{
string abc[6]={"ali","basit","cat","doll","evo","frnd"};

int lower=0;
int upper=5;
char a='y';
int mid=(upper+lower)/2;
string z;
cout<<"SEARCH NAME"<<endl;
cin>>z;
while(a=='y')
{
while (lower<=upper && z!=abc[mid])
{
mid = (upper+lower)/2;
if ( z==abc[mid])
{
cout<<"NAME IS FOUND: "<<abc[mid]<<endl;
cout<<"AT LOCATION: "<<mid+1<<endl;
}
else if (z>abc[mid])
{
lower= mid + 1;
}
else
upper=mid-1;
}
cout<<"do another(y/n)? "<<endl;
cin>>a;
}
}

You might also like