Linear search program in c using recursion

This program runs linear search recursively in an array c++ code

Concept used:
  • Recursive function Linear Search
  • if else statement


How Program Works
  • Program takes size of array
  • Input elements in array
  • Passing array, key and size to the recursive function recursiveLinearSearch(int array[],int key, int size)
  • Recursive function calls it self until certain conditions fulfill
  • Function returns 1 if record found in array else returns -1



C++ code:
C++ program linear search program using recursive function



    #include<iostream>
    using namespace std;
  
    int recursiveLinearSearch(int array[],int key,int size){
    size=size-1;
      if(size <0){
      return -1;
      }
      else if(array[size]==key){
      return 1;
      }
      else{
      return recursiveLinearSearch(array,key,size);
      }
    }

 
    int main() {
  
      cout<<"Enter The Size Of Array:   ";
    int size;
    cin>>size;
    int array[size], key,i;
    
    // Taking Input In Array
    for(int j=0;j<size;j++){
    cout<<"Enter "<<j<<" Element : ";
    cin>>array[j];
    }
    //Your Entered Array Is
    for(int a=0;a<size;a++){
       cout<<"array[ "<<a<<" ]  =  ";
       cout<<array[a]<<endl;
    }
    cout<<"Enter Key To Search  in Array";
    cin>>key;
    int result;
    result=recursiveLinearSearch(array,key,size--);
    if(result==1){
    cout<<"Key Found in Array  ";
    }
    else{
    cout<<"Key NOT Found in Array  ";
    }
       return 0;
    }
Linear search program in c++ using recursion code end


More Programs.
Linear Search in  C++

Find Prime Number in C++

For more learning change the program and examine the output
Read More..

Reasons Why Hosted PBX Canada Is Superior Solution

By Jerri Perry


A small business user might require setting main concern for incoming calls according to the clients. There are numerous tasks in addition to put up the call receiving or make priority such as compound dialing, personalized message play while on hold, call forwarding, call holding, , call footage and many more. These tasks are professionally carried out by hosted pbx Canada providers supporting VOIP technology.

The virtual systems are VoIP compatible. One can access all the roles of expensive telephone systems at a fraction of the cost through a PBX phone system. The available features include but may not limited to virtual receptionist, auto attendant, call forwarding, fax mail, voice-mail as well as caller ID. All these features are offered by way of dedicated phone lines and thus the probability of missing any call is minimal.

The service providers allow the users to connect to this system on payment of a nominal subscription amount. This type of solution, typically known as the private branch exchange services offers the same facilities with additional advantages delivered by hosting. Hosting of the telephony system relieves the business users from the worries of maintaining, repairing the system on their own.

Right from the repairing, upkeep and maintenance of the system is taken care of the service providers offering hosted services for the users. The service providers offer their customers a web based interface to connect to the hosted solution and use it as the real equipment. Its common advantages can are many.

The solution can be used by simply installing an application supporting the web based interface. Installing this application at the end of the user is simple. From the network of the user connected personal computer or smart phone, the data is transmitted through hosted private branch exchange service provider in the form of data packets. So with mere installation of this VOIP phone application the users can start using the service.

This raises the expenses involved since the system will be your responsibility. Virtual PBX on the other hand is not a physical asset. It is just a service and thus, if the system wears out, it will be the responsibility of the service provider to get the system replaced or repaired and you will just be concerned with the service provided.

From setting a call making and receiving time to forwarding to one number or different numbers simultaneously or sequentially everything can be set by the user. One can also increase or decrease the number of extensions as per the need and the billing is done as per the actual usage. The charges for availing these services too are very cost effective.

The Systems are your portable business phone systems that you can carry with you. You can enjoy a greater downloaddom and flexibility and dont just have to stick to your workstation. Whether you are in the office or not you will ever have a missed call again.The hosted pbx Canada Systems no doubt are a boon for the small and tiny business organizations as the best business phone systems and offer reliable, cost effective and top of the class features for a professional image.




About the Author:



Read More..

Need A New Desktop Computer Learn Which Is The Best Bet Here

By Lee Smith


Are you in the market for a new computer? Have you begun shopping for a new computer, but dont know what you are looking for? You arent alone. Many people get confused when it comes to computer shopping. Read on to get some great suggestions how to simplify the entire process.

Always have anti virus on your desktop. Without such a program, malicious software may infect your system. Malicious software programs can hijack your personal information and slow down your computer processing speed. There are several programs available that can scan and repair your computer regularly.

Try and find somebody who is giving away their desktop computer. A lot of people are making the shift to laptops and tablets, so they are attempting to sell their desktop computers for an affordable price. Usually, these computers are in good shape, but before making an offer, be sure that the computer works fine.

If you desktop is slow you can do a boot check to get more speed. You will be able to find this information in the start menu. Then, check out programs that are starting when you start your computer. If there are some listed you do not use often, disable them. Your computer is going to run a lot faster when you do this.

Look for the desktop computer model that suits your needs without exceeding your budget by too much. A lot of people look for machines with too many expensive add-ons that they will really never use. Be selective about the features and components in your desktop purchase to save money.

Compile a list of the tasks you plan to use your computer for, prior to shopping. Which computer you buy is going to have to do with what operations and activities you will be doing. If you intend to do serious gaming, your hardware requirements are going to be much higher than someone who just surfs the Internet.

Check out various reputable tech sites to evaluate any computer before making the decision to buy it. The many available choices can be overwhelming, but checking out reviews or the "editors pick list" will help you decide which computer is worth the money.

Youll need to consider a few things when buying a high-end gaming computer. Your system needs a solid video card, no less than 4 GB in memory and a higher resolution display. You can also get keyboards and controllers specially designed for a better play experience.

Be diligent in your purchasing; a great deal of the information is now online instead of in a booklet. Check out the online information before you purchase to make sure it meets your needs.

Make sure the software on the computer you want to buy is legal. You always should have the key and CD to be sure you wont end up in legal hot water or arent allowed to get later software updates.

Does the computer have enough memory? This is important when purchasing a PC. Will you need a lot of space? Will you be adding a large number of pictures?

Read reviews about computers online. Dont choose a desktop solely on price or looks. Most of the time, cheap computers are that price for a reason.

Are you someone who needs storage for lots of pictures? Memory questions are very common from desktop computer shoppers and you should be able to get good advice from retail store personnel as well as the computer manufacturer about memory capacity and issues for specific desktop computers.

Do not be worried! You have gained more than enough information to begin searching for your perfect computer. It is even possible to print out this article and bring it with you. If youre still in need of assistance, an employee can assist you finding the computer that best fits your needs.




About the Author:



Read More..

How To Get The Best Iphone Repair Auckland Technicians Offer

By Marcie Raymond


Smart phones of today can do a lot of amazing things. Still it doesnt mean that their users are saved from encountering all sorts of problems from time to time. When the unit seems to be no longer in its excellent state, its important for the owner to avail of iPhone repair Auckland technicians are providing to have the mobile phone thoroughly checked and restored.

Its not a challenging task to find a top-notch service these days. Because there are many people relying on their smart phones, there are plenty of technicians ready to lend a hand. Other than land-based ones, many are also conveniently providing their services on the internet. Regardless which one is preferred, the job has to be done only by highly qualified people.

Getting the personal recommendations of people you trust is one of the quickest and most reliable ways to find a reputable repairman or service center. Its not unlikely for the iPhones of your relatives and friends to have exhibited issues in the past. These individuals can speak for the excellence of the technicians they suggest, and their phones can serve as evidence.

Look for someone who once encountered the same kind of problem you are facing. This helps in increasing the chances that your smart phone is going to be taken to a technician who can really deal with the issue. It is also a huge plus if your device is taken to an establishment where accessories and parts are readily available in case certain components need to be replaced.

Logging on the internet helps save anyone from the need to scour the area just to find an establishment where his or her unit may be taken to. Using the preferred search engine, a mobile phone user can obtain a listing of local service providers in a snap. A lot of them these days also have their respective websites for their current and prospective customers to access.

Checking out the website allows the individual to know about the kind of services being offered. Because there are all sorts of issues which may be encountered by a mobile phone user, its important to look for technicians that can deal with the particular problem around. Often, getting a quote online may be done to ensure that the pocket wont end up empty.

The internet also has a wealth of consumer reviews and testimonials. When looking for these things, the person should be certain that his or her computer screen displays only honest and unbiased ones. Especially because the involved smart phone doesnt come with a cheap price tag, its owner should ensure that the unit is going to be left in good hands.

The moment a smart phone begins to exhibit signs that there is something wrong with it, buying a brand new unit isnt always the next move. Getting an iPhone repair Auckland technicians are providing is usually enough to take it back to its former glory. The mobile phone user should look for a reputable service center being trusted by a lot of tech-savvy consumers.




About the Author:



Read More..

Insertion and Deletion of elements in an Array

Suppose you are storing temperature data for a few months and you forgot to
store the temperature of a particular day (say 5th day) then you need to INSERT
that temperature after the 4th element of the array and in the other case if
you accidentally stored duplicate data then you need to DELETE the duplicate
element.


Apart from these simple examples, there are many other uses of insertion and
deletion


The array to which the element is to be inserted or deleted can be of two types
unordered (unsorted) and ordered (sorted). Here we will be discussing about
the insertion and deletion of element in an unordered or unsorted array.


For insertion in these types of arrays, we need to have two information, the
element to be inserted and the position to which it will be inserted. For deletion,
we only need the position.


Suppose we have the following array:


arr[5]={5,7,2,1,3}


And we need to insert the element 6 at the 2nd position, after insertion:


arr[5]={5,6,7,2,1}


Notice how the last element of the array (i.e. 3) has gone out to compensate
for the insertion.


Now, suppose we wish to delete the element at position 3rd, after deletion:


arr[5]={5,6,2,1,0}


We see, all the elements after the 3rd have shifted to their left and the vacant
space is filled with 0.


That’s exactly how insertion and deletion are done!


Algorithm for Insertion of an element in an array


Suppose, the array to be arr[max], pos to be the position
at which the element num has to be inserted. For insertion,
all the elements starting from the position pos are shifted
towards their right to make a vacant space where the element num is
inserted.




  1. FOR I = (max-1) TO pos
    arr[I] = arr[I-1]



  2.  arr[I] = num



Yeah it is that simple!


Algorithm for Deletion of an element in an array


Suppose, the array to be arr[max], pos to be the position
from which the element has to be deleted. For deletion, all the elements to
the right of the element at position pos are shifted to their
left and the last vacant space is filled with 0.




  1. FOR I = pos TO (max-1)
    arr[I-1] = arr[I]



  2. arr[I-1] = 0



Now, to illustrate all this let me show you a simple example program:


  // Example Program to illustrate
// insertion and deletion of
// elements in an array

#include<iostream.h>

// array has been declared as
// global so that other functions
// can also have access to it
int arr[5];

// function prototype
void a_insert(int, int);
void a_delete(int);

void main(void)
{
int ch;
int num,pos;

while(ch!=4)
{
cout<<"1> Insert";
cout<<"
2> Delete";
cout<<"
3> Show";
cout<<"
4> Quit
";

cin>>ch;

switch(ch)
{
case 1:
cout<<"enter element:";
cin>>num;
cout<<"enter pos.:";
cin>>pos;

a_insert(num,pos);
break;

case 2:
cout<<"enter pos.:";
cin>>pos;
a_delete(pos);
break;

case 3:
cout<<"
Array:";
for(int i=0;i<5;i++)
cout<<arr[i]<<" ";
break;
}
cout<<"
";
}
}

// insertion function
void a_insert(int num, int pos)
{
for(int i=4; i>=pos;i--)
arr[i]=arr[i-1];
arr[i]=num;
}

  // deletion function
void a_delete(int pos)
{
for(int i=pos; i<=4;i++)
arr[i-1]=arr[i];
arr[i-1]=0;
}

Good-Bye!



Related Articles:


Read More..

Web 2 0 Extremely easy web programming

While I am busy working on Liberty BASIC v5.0, my development partner Scott is working on something fun on the side. We are working on a dynamic web front end to Liberty BASIC so that you can write web programs in LB. We have some ideas for a unique tool for web programming that doesnt require all the crazy bits and pieces that are needed for the mainstream web solutions.

This will be an all-in-one solution with its own web server and it can be hosted behind Apache if so desired. We hope that in a month or so we will have a neat demo site up with some example pages that show how it works.

So, theres lots going on! :-)
Read More..

Square triangle2

Q. write a C program to display the character in following fashion:


ABCDCBA
 ABCBA
  ABA
   A
Ans.

#include<stdio.h>
#include<conio.h>
int main()
{
  char ch,r,c;
  int sp;
  printf("
Enter last character of triangle : "
);

  scanf("%c",&ch);
  if(ch>=a && ch<=z)
      ch=ch-32;
  printf("
"
);

  for(r=A; A<=ch; ch--,r++)
  {
    for(sp=r; sp>A; sp--)
       printf(" ");
    for(c=A; c<=ch; c++)
       printf("%c",c);   
    for(c=ch-1; c>=A; c--)
       printf("%c",c);
    printf("
"
);

  }
  getch();
  return 0;
}

/*************** OUTPUT**************/

Read More..