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 |
HOW TO GET "H1B" -VISA 4 USA FOR MY SON?HE HAD COMPLETED "MS"(IT)FROM AUSTALIA 2007.I AM WORKING IN U.S.A.
what is electronic software
Difference between Structure and Class in C++?
write a program that input four digit no and finds it is palindrome or not
Give the output of the following program main() {int ret; ret=fork();ret=fork();ret=fork();ret=fork(); if(!ret) printf("sun"); else printf("solaris");
What is the disadvantage of templates ?
write a c++ program to create an object of a class called employee containing the employee code name designation basic salarry HRA Da gross salary as data 10 such objects "members process "
what's the difference between abstract class and concreate class? what's the meaning of standard template library(STL)?
When did c++ add stl?
what is a template?
2 Answers Amazon, BITS, IBS, Wipro,
What does stl mean in slang?
give me the defination of inheritance?