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
What are c preprocessors?
can any one please explain, how can i access hard disk(physical address)? it is possible by the use of far,near or huge pointer? if yes then please explain......
How does free() know explain how much memory to release?
Is a house a shell structure?
What is 1f in c?
Why we not create function inside function.
What is array in c with example?
Where can I get an ansi-compatible lint?
What is extern variable in c with example?
How can you find out how much memory is available?
How to draw the flowchart for structure programs?
Explain the difference between ++u and u++?
I completed my B.tech (IT). Actually I want to develop virtual object that which will change software technology in the future. To develop virtual object what course I have to take. can I any professor to help me.
How does selection sort work in c?
When should you use a type cast?