write a program to search for an element in a given array.
If the array was found then display its position otherwise
display appropriate message in c language
Answer Posted / aishwarya rajan
#include<iostream.h>
#include<conio.h>
void main()
{
int i,n,a[30];
char item;
cout<<"Enter the number of elements you would like to enter in the array: ";
cin>>n;
for(i=0;i<n;i++)
{
cout<<"Enter the element"<<i+1<<" :";
cin>>a[i];
}
cout<<"Enter the element you are searching for in the array:";
cin>>item;
if(a[i]==item)
cout<<"The item does exist in the array!! it is the "<<i+1<<" element!!";
else
cout<<"The item is not found in the array!!";
getch();
}
| Is This Answer Correct ? | 0 Yes | 2 No |
Post New Answer View All Answers
Is using exit() the same as using return?
An instruction which is analysed and acted upon by the processor prior to the compiler going its work a) directive b) constructive c) constant d) absolute mode
why programs in c are running with out #include
Do you know the difference between malloc() and calloc() function?
Explain how do you determine whether to use a stream function or a low-level function?
What are the various types of control structures in programming?
explain what is fifo?
Write a program to print ASCII code for a given digit.
When should volatile modifier be used?
What is the code for 3 questions and answer check in VisualBasic.Net?
write a program to reverse a every alternetive words in a string in a place. EX: Input is "this is the line of text" Output should be "shit is eht line fo text" Please any one tell me code for that.
Can math operations be performed on a void pointer?
What are the similarities between c and c++?
Why structure is used in c?
What is integer constants?