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
c programs are converted into machine language with the help of a) an interpreter b) a compiler c) an operatinf system d) none of the above
Is it possible to use curly brackets ({}) to enclose single line code in c program?
What are multidimensional arrays?
what is the difference between 123 and 0123 in c?
Explain what is the difference between functions abs() and fabs()?
What is local and global variable in c?
Describe the order of precedence with regards to operators in C.
What are the __date__ and __time__ preprocessor commands?
What is nested structure in c?
if the area was hit by a virus and so the decrease in the population because of death was x/3 and the migration from other places increased a population by 2x then annually it had so many ppl. find our the population in the starting.
a=10;b= 5;c=3;d=3; if(a printf(%d %d %d %d a,b,c,d) else printf("%d %d %d %d a,b,c,d);
What is a scope resolution operator in c?
What is a method in c?
Explain About fork()?
Does sprintf put null character?