Earn by twitter on twivert

Sign up for PayPal and start accepting credit card payments instantly.

Thursday, March 29, 2012

WAP of Linear Search in C++

/*WAP of Linear Search in C++*/
#include<iostream.h>
#include<conio.h>

class linearSearch
{
 int size, a[100],item;
 public:
 void setData();
 void searchItem();

};
void linearSearch :: setData()
{
 int i;
 cout << "\nEnter total number of elements: " ;
 cin >> size;

 
 cout << "\nEnter elements: ";
 for(i=0;i> a[i];

 cout << "\nEnter Item which you want to find: ";
 cin >> item;

}
void linearSearch :: searchItem()
{
 int k=1, loc=0;
 while(loc==0 && k<=size)
 {
  if(item == a[k-1])
  {
   loc = k;
  }
  k +=1;
 }
 if(loc==0)
  cout << "\n" << item << " isn't Found.";
 else
  cout << "\n" << item << " at Location " << loc;
}

void main()
{
 clrscr();
 linearSearch bsrch;
 bsrch.setData();
 bsrch.searchItem();

 getch();
}

No comments:

Post a Comment

ADS

How to earn online

How to earn online:
Step - 1 :
signup for PayPal, to recieve your online earning
click here:
https://www.paypal.com/in/mrb/pal=CZ7224TZBMCBL
step - 2 : Singup these 4 sites & earn & enjoy! Read site to know how to earn.
1. trekpay
Earn up to $0.02 (2 cents) per click.
http://www.trekpay.com/?ref=34690
2. neobux
Earn up to $0.02 (2 cents) per click.
Click here:
http://www.neobux.com/?r=Moneyearner786

AddMe

Bookmark and Share