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
Is this program statement valid? INT = 10.50;
Why does notstrcat(string, "!");Work?
Explain what is #line used for?
what do you mean by inline function in C?
Explain how do you convert strings to numbers in c?
how to print the character with maximum occurence and print that number of occurence too in a string given ?
What are the advantages of using linked list for tree construction?
Can you apply link and association interchangeably?
how can I convert a string to a number?
What are extern variables in c?
What are the parts of c program?
What is switch in c?
What is keyword in c?
Explain the red-black trees?
What is the difference between NULL and NUL?