Certificate: Harshit Roy of Class Xiith of Bishop Conrad
Certificate: Harshit Roy of Class Xiith of Bishop Conrad
………………………… ………………………
RAVI KUMAR SIR SR. MERCY JOHN K
(COMPUTER TEACHER) (PRINCIPLE)
……………………………
EXAMINER SIGNATURE
ACKNOWLEDGEMENT
I have taken efforts in this project. However, it
would not have been possible without the kind
support and help of many individuals. I would
like to extend my sincere thanks to all of
them.
I am highly indebted to my teacher “Ravi Sir”
for their guidance and constant supervision as
well as for providing necessary information
regarding the project & also for his support in
completing the project.
I would like to express my gratitude towards
my parents for their kind co-operation and
encouragement which help me in completing
of this project.
I would like to express my special gratitude
and thanks to my friends for giving me such
attention and time in developing the project.
Harshit Roy
XIIth
Q-1) WRITE A PROGRAM TO ACCEPT AN ARRAY OF N ELEMENTS & SEARCH AN
ELEMENT USING BINARY SEARCH TECHNIQUE.
ANS) #include<iostream.h>
#include<conio.h>
void main()
int s,l,i,n,k,a[150],f=0;
clrscr();
cin>>n;
for(i=0;i<n;i++)
Co``````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````
`ut<<i+1<<" Element -";
cin>>a[i];
cin>>k;
s=0,l=n-1;
while(s<=l)
int mid=(s+l)/2;
if(k>a[mid])
s=mid+1;
else if(k<a[mid])
l=mid+1;
else
f=1;
break;
if(f==1)
cout<<" Found";
else
getche();
ANS) #include<iostream.h>
#include<conio.h>
void main()
clrscr();
int n,i,j,a[150],temp;
cin>>n;
for(i=0;i<n;i++)
cin>>a[i];
for(i=0;i<n;i++)
for(j=0;j<n-1-i;j++)
if(a[i]>a[j+1])
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
for(i=0;i<n;i++)
cout<<a[i]<<endl;
}
getche();
Q-3)WRITE A PROGRAM TO ACCEPT TWO ARRAYS & THEIR SIZE RESPECTIVELY &
MERGE THEM (ASSUMING THE FIRST ARRAY IN ASCENDING ORDER , SECOND ARRAY
IN DESCENDING ORDER & THE RESULTANT ARRAY IN DESCENDING ORDER).
ANS) #include<iostream.h>
#include<conio.h>
void main()
clrscr();
int n,m,i,j,k,a[100],b[100],c[200];
cout<<" Enter the number of elements you want to enter in array 1 = ";
cin>>n;
for(i=0;i<n;i++)
cin>>a[i];
cout<<" Enter the number of elements you want to enter in array 2 = ";
cin>>m;
for(i=0;i<m;i++)
cin>>b[i];
i=n-1,j=0,k=0;
if(a[i]>b[j])
c[k]=a[i];
i--,k++;
else if(b[j]>a[i])
c[k]=b[j];
j++,k++;
else
c[k]=a[i];
i--,k++,j++;
while(i>=0)
{
c[k]=a[i];
i--,k++;
while(j<m)
c[k]=b[j];
j++,k++;
for(i=0;i<k;i++)
cout<<c[i]<<” ”;
getche();
}
Q-4)WRITE A PROGRAM TO ACCEPT AN ARRAY OF N ELEMENTS AND DELETE AN
ELEMENT FROM THE ARRAY WHERE POSITION OF ELEMENT IS GIVEN.
ANS) #include<iostream.h>
#include<conio.h>
void main()
clrscr();
int n,i,p,a[100];
cin>>n;
for(i=0;i<n;i++)
cin>>a[i];
cin>>p;
if(p<=n)
p--;
for(i=p;i<n;i++)
a[i]=a[i+1];
n--;
for(i=0;i<n;i++)
cout<<a[i]<<endl;
getche();
ANS) #include<iostream.h>
#include<conio.h>
void main()
clrscr();
int n,m,p,a[100],i,f;
cin>>n;
for(i=0;i<n;i++)
cin>>a[i];
cin>>m;
f=0;
for(i=0;i<n;i++)
if(m<a[i])
p=i,f=1;
break;
}}
if(f==0)
a[n]=m;
else
for(i=n-1;i>=p;i--)
a[i+1]=a[i];
a[p]=m;
n++;
cout<<" New array is \n";
for(i=0;i<n;i++)
cout<<a[i]<<endl;
getche();