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
When I tried to go into a security sites I am denied access and a message appeared saying 'applet not initialize'. How can I rectify this problem.
What are register variables? What are the advantage of using register variables?
Can we compile a program without main() function?
code for replace tabs with equivalent number of blanks
What are the features of c languages?
What is action and transformation in spark?
how can i access hard disk address(physical address)? are we access hard disk by using far,near or huge pointer? if yes then please explain.....
Are there constructors in c?
What is c++ used for today?
What is the difference between typedef struct and struct?
What does #pragma once mean?
Write a function expand(s1,s2) that expands shorthand notations like a-z in the string s1 into the equivalent complete list abc...xyz in s2 . Allow for letters of either case and digits, and be prepared to handle cases like a-b-c and a-z0-9 and -a-z. z-a:zyx......ba -1-6-:-123456- 1-9-1:123456789987654321 a-R-L:a-R...L a-b-c:abbc
What are bitwise shift operators in c programming?
What does the c in ctime mean?
What is variable in c example?