mirror of
https://github.com/TheAlgorithms/C
synced 2024-11-22 13:31:21 +03:00
Create linears.c
This commit is contained in:
parent
b895794da8
commit
d607eae61d
26
Searches/linears.c
Normal file
26
Searches/linears.c
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
#include<stdio.h>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
int a[20],i,x,n;
|
||||||
|
printf("How many elements?");
|
||||||
|
scanf("%d",&n);
|
||||||
|
|
||||||
|
printf("Enter array elements:\n");
|
||||||
|
for(i=0;i<n;++i)
|
||||||
|
scanf("%d",&a[i]);
|
||||||
|
|
||||||
|
printf("\nEnter element to search:");
|
||||||
|
scanf("%d",&x);
|
||||||
|
|
||||||
|
for(i=0;i<n;++i)
|
||||||
|
if(a[i]==x)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if(i<n)
|
||||||
|
printf("Element found at index %d",i);
|
||||||
|
else
|
||||||
|
printf("Element not found");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user