write a program to search and display the position of an
element in a single-dimentional array using function.
Answer / bharat varlekar
#include<iostream.h>
•
#include<conio.h>
#include<process.h>
#define max 10
void main()
{
clrscr();
int X[max],i,item;
for(i=0;i<max;i++)
{
cout<<”Enter “<<”X[“<< i<<”]”<<” element “;
cin>>X[i];
}
cout<<”The item to search: “;
cin>>item;
for(i=0;i<max;i++)
{
if(X[i]==item)
{
cout<<”\nItem found at “<<i+1<<” position”;
getch();
exit(1);
}
}
cout<<”\nItem not found”;
getch();
}
Output
Enter X[0] element 21
Enter X[1] element 21
Enter X[2] element 22
Enter X[3] element 35
Enter X[4] element 28
Enter X[5] element 29
Enter X[6] element 26
Enter X[7] element 23
Enter X[8] element 26
Enter X[9] element 11
The item to search: 23
Item is found at 8 position
| Is This Answer Correct ? | 5 Yes | 0 No |
Difference between Structure and Class in C++?
Assume I have a linked list contains all of the alphabets from "A" to "Z?" I want to find the letter "Q" in the list, how does you perform the search to find the "Q?"
draw a flowchart that accepts two numbers and checks if the first is divisible by the second.
write a program that will accept a number and print.its equivalent in words the maximum input number is 9999
What is Constructor
what are you now programming Languages C+
What do you mean by stl?
Write a program in C++ returning starting locations of a substring using pointers
i want a road rash 3d game code if some one know please help me
How does an stl file work?
What is a standard template library (stl)? What are the various types of stl containers?
Diffrernce Between Overloading and Overriding?