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
WRITE A PROGRAM TO MERGE TWO SORTED ARRAY USING MERGE SORT TECHNIQUE..
What is the difference between a free-standing and a hosted environment?
What is the incorrect operator form following list(== , <> , >= , <=) and what is the reason for the answer?
What is the difference between c and python?
When do we get logical errors?
Can stdout be forced to print somewhere other than the screen?
Is there sort function in c?
Write a program of prime number using recursion.
Is c weakly typed?
can any one provide me the notes of data structure for ignou cs-62 paper
What is a program flowchart and how does it help in writing a program?
What does sizeof int return?
How to write a multi-statement macro?
What is the difference between char array and char pointer?
What are the features of the c language?