0% found this document useful (0 votes)
52 views

Certificate: Harshit Roy of Class Xiith of Bishop Conrad

This document contains a certificate, acknowledgements, and answers to 5 programming questions involving arrays. The certificate certifies that a student completed a project on programming. In the acknowledgements, the student thanks their teacher, parents, and friends for their support and guidance during the project. The questions and answers cover topics like binary search of an array, bubble sorting an array, merging two sorted arrays, deleting an element from an array, and inserting a new element into a sorted array.

Uploaded by

Harshit Roy
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
52 views

Certificate: Harshit Roy of Class Xiith of Bishop Conrad

This document contains a certificate, acknowledgements, and answers to 5 programming questions involving arrays. The certificate certifies that a student completed a project on programming. In the acknowledgements, the student thanks their teacher, parents, and friends for their support and guidance during the project. The questions and answers cover topics like binary search of an array, bubble sorting an array, merging two sorted arrays, deleting an element from an array, and inserting a new element into a sorted array.

Uploaded by

Harshit Roy
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 12

CERTIFICATE

This is to certify that it’s bonafide work of


Harshit Roy of class XIIth of Bishop Conrad
senior secondary School.
He has done this project report in the
academic year 2019-20 for CBSE board under
the guidance of Ravi Sir.
Project report is in computer science on the
topic PROGRAMMING.

………………………… ………………………
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();

cout<<" Enter number of element which you want to enter - ";

cin>>n;

cout<<" Enter elements in sorted order for binary search -"<<"\n";

for(i=0;i<n;i++)

Co``````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````
`ut<<i+1<<" Element -";

cin>>a[i];

cout<<" Enter element which you want to search - ";

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

cout<<" Not Found";

getche();

Q-2)WRITE A PROGRAM TO ACCEPT AN ARRAY OF N ELEMENTS & SORT IT USING


BUBBLE SORT TECHNIQUE.

ANS) #include<iostream.h>

#include<conio.h>

void main()

clrscr();
int n,i,j,a[150],temp;

cout<<" Enter number of elements which you want to enter - ";

cin>>n;

cout<<" Enter elements "<<endl;

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;

cout<<" Sorted array is - \n";

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;

cout<<" Enter the elements in ascending order "<<endl;

for(i=0;i<n;i++)

cin>>a[i];
cout<<" Enter the number of elements you want to enter in array 2 = ";

cin>>m;

cout<<" Enter the elements in desending order "<<endl;

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

cin>>b[i];

i=n-1,j=0,k=0;

while(i>=0 && j<m)

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++;

cout<<" New merged array in descending order "<<endl<<endl;

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];

cout<<" Enter number of elements you want to enter in array = ";

cin>>n;

cout<<" Enter elements -"<<endl;

for(i=0;i<n;i++)

cin>>a[i];

cout<<"Enter position of element you want to delete = ";

cin>>p;

if(p<=n)

p--;

for(i=p;i<n;i++)

a[i]=a[i+1];

n--;

cout<<" New array is \n";

for(i=0;i<n;i++)

cout<<a[i]<<endl;
getche();

Q-5)WRITE A PROGRAM TO ACCEPT AN ARRAY & INSERT A NEW ELEMENT IN THE


ARRAY, WHERE THE ARRAY IS IN INCREASING ORDER.

ANS) #include<iostream.h>

#include<conio.h>

void main()

clrscr();
int n,m,p,a[100],i,f;

cout<<" Enter number of elements you want to enter in array = ";

cin>>n;

cout<<" Enter elements in incresing order -"<<endl;

for(i=0;i<n;i++)

cin>>a[i];

cout<<"Enter element which is to be inserted = ";

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();

You might also like