Posted by MindBreaker at 2:01 AM
Read our previous post
Write a program which uses
Binary Search to search the elements 52,and 33 and print it.
Source Code;
//////////////////
insertion
#include <iostream>
using namespace std;
void
main()
{
int ary[11],n,index,value,increment,total,index1,temp;
cout<<"Enter
values 10 value : ";
for(n=0;n<10;n++)
{
cin>>ary[n];
}
cout<<"Enter
value in index: "<<endl;
cin>>value;
cout<<""<<endl;
ary[10]=value;
for(n=0;n<10;n++)
{
if(ary[n]>ary[n+1])
{
temp=ary[n];
ary[n]=ary[n+1];
ary[n+1]=temp;
}
}
for(n=0;n<11;n++)
{cout<<ary[n]<<" , ";}
}
Output:
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.