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 / sharan
#include<stdio.h>
#include<conio.h>
void main()
{
int a[5],i;
int ele,temp=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
// searching for the element
for (i=0; i<5; i++)
{
if (a[i]==ele)
{
temp=1;
printf("Element found %d , position=%d\n",ele,i);
}
}
if (!temp)
printf("Element not found\n");
} // end of main()
| Is This Answer Correct ? | 149 Yes | 97 No |
Post New Answer View All Answers
Explain the difference between malloc() and calloc() in c?
What is LINKED LIST? How can you access the last element in a linked list?
What are unions in c?
Write a program to generate a pulse width frequency of your choise,which can be variable by using the digital port of your processor
Explain how do you list files in a directory?
What is the maximum no. of arguments that can be given in a command line in C.?
Explain what is a pragma?
what are non standard function in c
Compare interpreters and compilers.
Is there a way to jump out of a function or functions?
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
Explain what are the standard predefined macros?
Differentiate between the = symbol and == symbol?
Explain what is the best way to comment out a section of code that contains comments?
When can a far pointer be used?