Linear Search in C

Google Advertisements

Prev Tutorial Next Tutorial

Linear Search in C

Linear search is also called as sequential search. Linear search is a method for finding a particular value in a list. In this searching technique you need to check every elements one by one until desired element found.

Example of Linear Search

	
#include<stdio.h>
#include<conio.h>

void main()
{
int i,a[50],num,size;
clrscr();
printf("Enter Size of array: ");
scanf("%d",&size);
printf("Enter %d element in array: \n",size);
for(i=0;i<size;i++)
{
scanf("%d",&a[i]);
}
printf("Enter element for search: ");
scanf("%d",&num);
for(i=0;i<size;i++)
{
if(a[i]==num) // if element is found
{
printf("\n%d is present at %d position",num,i+1);
break;
}
}
if(i==size)
{
printf("\n %d is not found",num);
}
getch();
  }

Output

	
Enter Size of array: 5
Enter 5 element in array
10
6
4
12
20
Enter element for search: 4
4 is present at 3 position
binary search
Prev Tutorial Next Tutorial

Google Advertisements

Buy This Ad Space @$50 per Month, Ad Size 600X200 Contact on: hitesh.xc@gmail.com or 8076671483

Pure VPN Privide Lowest Price VPN Just @ $1.65. Per Month with Non Detected IP Lowest Price Non Detected IP VPN

Magenet is best Adsense Alternative here we earn $2 for single link, Here we get links ads. Magenet

Cloud computing is the on demand availability of computer system resources, especially data storage and computing power, without direct active management by the user. Cloud Computing Tutorial

College Projects Related to Java, AWT, C Projects for College, C++ Projects for College, Android Projects. Download Java C C++ Projects

Download Projects

Adsense Advertisements


Buy This ads Space 8076671483

Buy This Ad Space @$120 per Month, Ad Size 300X600 Contact on: hitesh.xc@gmail.com or 8076671483 Try this Keyword C++ Programs