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
which is an algorithm for sorting in a growing Lexicographic order
What is C language ?
Explain what is the difference between #include and #include 'file' ?
What is the difference between null pointer and wild pointer?
What is a union?
What is a macro in c preprocessor?
7-Given an index k, return the kth row of the Pascal's triangle. For example, when k = 3, the row is [1,3,3,1]. For reference look at the following standard pascal’s triangle.
How do you view the path?
What are global variables and explain how do you declare them?
How can I discover how many arguments a function was actually called with?
Is c easy to learn?
How can I read a binary data file properly?
What is the difference between far and near ?
Is c object oriented?
What is hash table in c?