top of page

Linear Search In C

Writer's picture: Code CrazeCode Craze


#include<stdio.h>

void main()

{

int size;

printf("\nEnter the size of array : ");

scanf("%d",&size);

int a[size];

int i=0,e,count=0;

for(i=0;i<size;i++)

{

printf("\nEnter element : ");

scanf("%d",&a[i]);

}

printf("\nArray : ");

for(i=0;i<size;i++)

{

printf("\t%d",a[i]);

}

printf("\nEnter element to search : ");

scanf("%d",&e);

for(i=0;i<size;i++)

{

if(e==a[i])

{

count+=1;

printf("\nElement found successfully🙂🙂🙂!");

}

}

if(count==0)

{

printf("\nSorry! element is not found😅😅😅!");

}

}

0 views0 comments

Recent Posts

See All

Stack Using Queue

A stack can be implemented using two queues in C. The basic idea is to use one queue for enqueue operations and another for dequeue...

コメント


bottom of page