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 / e v n raja
#include<stdio.h>
#include<conio.h>
void main()
{
int a[5],i,ele;
clrscr();
printf("enter the array elements
");
for (i=0; i<5; i++)
scanf("%d",&a[i]);
printf("Enter the element to be search
");
scanf("%d",&ele);
// searching for the element
for (i=0; i<5; i++)
{
if (a[i]==ele)
{
printf("Element found %d , position==%d",ele,i);
break;
}
}
} // end of main()
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
Is main is user defined function?
what will be the output for the following main() { printf("hi" "hello"); }
What are global variables and explain how do you declare them?
What is the difference between if else and switchstatement
#include main() { enum _tag{ left=10, right, front=100, back}; printf("left is %d, right is %d, front is %d, back is %d",left,right,front,back); }
code for quick sort?
Why c is called top down?
How can I change the size of the dynamically allocated array?
How can you tell whether two strings are the same?
What are global variables?
Write a program to produce the following output: 1 2 3 4 5 6 7 8 9 10
What is the significance of scope resolution operator?
write a program to display all prime numbers
Given below are three different ways to print the character for ASCII code 88. Which is the correct way1) char c = 88; cout << c << " ";2) cout.put(88);3) cout << char(88) << " "; a) 1 b) 2 c) 3 d) constant
How to define structures? ·