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 |
why we are using the fork command?.. how it works?
Describe the My Computer and My Documents folders; identify the elements that are present in every Window.
Give two integer arrays A & B.A has n elements and B has ' n-1 ' elements . A has all the elements that are there in B. But B has one missing element. Write a function that takes arrays , A & B as imnput and finds the missing element in most optised manner .
I am doing my BS.c MATHS CAN I ABLE TO JOIN IN NIIT?
What is 2*2?
What is the stl, standard template library?
What is the underlying datastructure of map?
write a piece of c++ code which allocate memory to the 50 object of type CObj
how to overload << and >> operator in c++
Define the terms: field, record, table and database
In what cases using of a 'template' is a better approach then using of a 'base class'?
6 Answers Lucent, Mind Tree, Wipro,
if x<>=z then statement end what is the cyclomatic complexity