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 |
what is a template?
2 Answers Amazon, BITS, IBS, Wipro,
What is a stl vector?
Describe how to safeguard a system through acquisition of an antivirus Program and systematic backup.
What is the use of stl?
5. Write c++ function that would intake a string and return the number of occurrences of a given character in that sring Ex:- if the word is “Colombo” and count the occurrences of the letter “o” the function would return 3
sir please send me bpcl previous question papers
0 Answers BPCL Bharat Petroleum,
What does stl stand for in basketball?
why does the execution of a c++ program start with main()???
WHAT IS FIBONACCI SERIES?
write a program that will accept a number and print.its equivalent in words the maximum input number is 9999
What is the STL?
write a program to convert a decimal number in to its equivalent binary number?