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
What is #include cctype?
Why do we use header files in c?
What is a ternary operator in c?
If you know then define #pragma?
How many bytes is a struct in c?
What is a pragma?
how can I convert a string to a number?
What is the method to save data in stack data structure type?
How do I convert a string to all upper or lower case?
Write the Program to reverse a string using pointers.
List some of the static data structures in C?
write a program to print the consecutive repeated character from the given string... input string is : hhhhjkutskkkkkggggj output should be like this: hhhhkkkkkgggg anyone help me...
What is gets() function?
How do you determine whether to use a stream function or a low-level function?
What are the types of pointers in c?