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 / vs
#include<stdio.h>
#include<conio.h>
void main()
int a[5],i;
int e,t=0,p=0;
clrscr();
printf("enter the array of elements/n");
for(i=0;i<5;i++)
scanf("%d",&a[i]);
clrscr();
printf("enter the element to search/n");
scanf("%d",&e);
for(i=0;i<5;i++)
{
if(a[i]==e)
{
t=1;
p=i;
}
}
if(t==1)
printf("element found--%d/n position--%d",e,p);
else
printf("element not found/n");
getch();
}
| Is This Answer Correct ? | 21 Yes | 22 No |
Post New Answer View All Answers
How can I change the size of the dynamically allocated array?
what is a constant pointer in C
What is a null pointer assignment error? What are bus errors, memory faults, and core dumps?
How are structure passing and returning implemented?
Explain do array subscripts always start with zero?
What is #include called?
What are different types of pointers?
The postoder traversal is 7,14,3,55,22,5,17 Then ur Inorder traversal is??? please help me on this
What is a memory leak? How to avoid it?
Is it better to bitshift a value than to multiply by 2?
What is difference between stdio h and conio h?
What is the collection of communication lines and routers called?
What are comments and how do you insert it in a C program?
Why does this code crash?
What is #line used for?