Wed Oct 27, 2010 11:37 pm
#include<iostream>
using namespace std;
int seqsearch(int seq[],int size,int key)
{
int i;
for(i=size;i>0;i--)
{
if(seq[i]==key)
return i ;
} return -1 ;
}
int main()
{
int i;
int key;
int seq[]={0,1,2,3,4,5,6,7,8,9};
int x=seqsearch(seq,10,key);
cout<<"enter the key"<<endl;
cin>>key;
cout<<x<<endl;
return 0;
}
Sat Oct 30, 2010 12:16 am
for(i=size;i>=0;i--)
{
if(seq[i]==key)
return i ;
} return -1 ;
int main()
{
int i;
int key;
int seq[]={0,1,2,3,4,5,6,7,8,9};
cout<<"enter the key"<<endl;
cin>>key;
// Call the function after the entry of key
int x=seqsearch(seq,10,key);
cout<<x<<endl;
return 0;
}
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com
Powered by phpBB © phpBB Group.