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 / bishwas bidari
#include<stdio.h>
#include<conio.h>
void main()
{
int a[5],i;
int ele,temp=0,pos=0;
clrscr();
printf("enter the array elements\n");
for (i=0; i<5; i++)
{
scanf("%d",&a[i]);
}
printf("Enter the element to be search\n");
scanf("%d",&ele);
/* searching for the element*/
for (i=0; i<5; i++)
{
if (a[i]==ele)
{
temp=1;
pos=i;
}
}
if (temp==1)
printf("Element found %d , position==%d",ele,pos);
else
printf("Element not found\n");
}
| Is This Answer Correct ? | 85 Yes | 52 No |
Post New Answer View All Answers
Explain high-order and low-order bytes.
write a c program thal will find all sequences of length N that produce the sum is Zero, print all possible solutions?
What is a substring in c?
What is the difference between null pointer and wild pointer?
Is it possible to initialize a variable at the time it was declared?
explain what are pointers?
What is abstract data structure in c?
What is gets() function?
How do you list a file’s date and time?
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 the difference between text files and binary files?
What is exit() function?
How can I write a function that takes a format string and a variable number of arguments?
What does the c preprocessor do?
What is a const pointer?