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 / kapil hansrajani
include<stdio.h>
#include<conio.h>
void main()
{
int a[100],i,j,n;
clrscr();
printf("Enter the number of elements : ");
scanf("%d",&n);
printf("Enter the elements: ");
for(i=0;i<n;i++)
scanf("%d",&a[i]);
printf("Enter the element to search : ");
scanf("%d",&j);
for(i=0;i<n;i++)
{
if(a[i]==j)
{
printf("The position of the element %d is %d ",j,i);
break;
}
}
getch();
}
| Is This Answer Correct ? | 48 Yes | 26 No |
Post New Answer View All Answers
what are the program that using a two dimensional array that list the odd numbers and even numbers separately in a given 10 inputs values
What is || operator and how does it function in a program?
Explain what is gets() function?
Is there a built-in function in C that can be used for sorting data?
There is a practice in coding to keep some code blocks in comment symbols than delete it when debugging. How this affect when debugging?
Explain what’s a signal? Explain what do I use signals for?
how to find anagram without using string functions using only loops in c programming
What is gets() function?
Why pointers are used in c?
please explain every phase in the "SDLC" in the dotnet.
What is int main () in c?
Can you explain the four storage classes in C?
What are the 5 organizational structures?
which of the following is not a character constant a) 'thank you' b) 'enter values of p, n ,r' c) '23.56E-o3' d) all of the above
Write a program to produce the following output: 1 2 3 4 5 6 7 8 9 10