write a program to search and display the position of an
element in a single-dimentional array using function.
Answer Posted / 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 |
Post New Answer View All Answers
What is stl in c++ with example?
When did c++ add stl?
how to making game in c++ ?
What are stl algorithms?
What is stl language?
What is a standard template library (stl)? What are the various types of stl containers?
How does an stl file work?
totoo po ba ang manga aliens!
What are the various types of stl containers?
What is stl stack?
Q1. A. What is unary operator? List out the different operators involved in the unary operator. B. What is an adjust field format flag? Q2. A. Distinguish between a # include and #define. B. Can a list of string be stored within a two dimensional array? Q3. A.Explain how a pointer to function can be declared in C++? B.List the merits and demerits of declaring a nested class in C++? Q4. A. What are the syntactic rules to be avoid ambiguity in multiple inheritence? B. Explain the operation of overloading of an assignment operator. Q5. A. Explain how the virtual base class is different from the conventional base classes of the opps. B. Explain how an exception handler is defined and invoked in a Program. Q6. A. What is a binary file? List the merits and demerits of the binary file usagein C++. B. Write short notes on Text Manipulation Routines. C. Write bites in Turbo c++ Header (“Include”) Files.
Is there any error below, its a code to delete all entires from a map #include
How is stl different from c++ standard library?
Is stl open source?
How stl is different from the c++ standard library?