#include<stdio.h>
int main()
{
int i,n,search,item,a[100];
printf("How many array elements you want to enter\n");
scanf("%d",&n);
printf("Enter an array elements\n");
for(i=0;i<n;i++)
scanf("%d",&a[i]);
printf("which element you want to search\n");
scanf("%d",&item);
for(i=0;i<n;i++)
{
if(a[i]==item)
{
printf("%d element is fount at %d location",item ,i+1);
break;
}
}
if(i==n)
{
printf("%d element is not present in this array",item);
}
return 0;
}
INPUT 1:
How many array elements you want to Enter
5
Enter an array elements
11
22
33
44
55
which element you want to search
33
OUTPUT 1:
33 element is found at 3 location
INPUT 2:
How many array elements you want to Enter
5
Enter an array elements
11
22
33
44
55
which element you want to search
66
OUTPUT 1:
66 element is not present in this array
Monday, December 17, 2018
Home
/
Array Programs
/
C Programming
/
WAP in C to Search an element in an array using Linear Search
WAP in C to Search an element in an array using Linear Search
Topics
# Array Programs
# C Programming
About HindiKisseKahaniyaan
Easy Programming All is a free blogger to the students who wants to learn programming in C, HTML, CSS, Bootstrap, Web Designing from home. The students can learn programming free of cost at their home. We provide best logics about any program. If you want to ask any logic of any program you can comment to us in comment box.
C Programming
Labels:
Array Programs,
C Programming
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment