Answer to Question #235304 in C++ for Tarurendra Kushwah

Question #235304

Write the code for the following problem using either C or C++. If there are 8 cars with its car number {11,10,34,56,68,89,65,78} parked in a parking area, then you are looking for a car number 68 by checking every car sequentially from the beginning.


1
Expert's answer
2021-09-09T17:13:34-0400


#include <iostream>


using namespace std;


int Search(int arr[], int num){    
    for(int i=0;i<8;i++){    
        if(arr[i] == num){    
            return 1;    
        }    
    }    
        return -1;    
}
int main()
{
    int arr[8]={11,10,34,56,68,89,65,78};
    int num=68;
    int r=Search(arr,num);
	if (r==1)
	    cout<<"Search number is found!!!";
	else
	    cout<<"Search number is not found";


    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS