Professional Documents
Culture Documents
AbhishekDS1 2
AbhishekDS1 2
#include <iostream>
using namespace std;
int length;
cout<<"Enter Length of the Array : ";
cin>>length;
int arr[length];
for(int i=0;i<length;i++){
cout<<" [ ";
DEPARTMENT OF
ScreenShot of Code :
DEPARTMENT OF
ScreenShot of Output :
Code/Program Code :
DEPARTMENT OF
# #include<iostream>
while (start<=end)
{
int mid = (start+end)/2;
DEPARTMENT OF
if (arr[mid]==element)
{
return mid;
}
else if (arr[mid]>element)
{
end=mid-1;
} else {
start=mid+1;
} }
return -1;
} int main(){
DEPARTMENT OF
;
int flag = BinarySearch(arr,length,element); if
(flag!=-1)
{ cout<<"Element Found at index position :
"<<flag<<endl; cout<<"and position : "<<flag+1;
}
else{
cout<<"Entered Element is not present in the Array..!!!";
}
return 0;
}
DEPARTMENT OF
ScreenShot of Code :
DEPARTMENT OF
ScreenShot of Output :
3. Student Engagement in 5
Simulation/Demonstration/Performance
and Controls/Pre-Lab Questions.