Sequential Search Programs in C


Levels of difficulty: / perform operation:

C program to search a key number in an array using Sequential Search Method.

Program

  
#include <stdio.h>
#include <conio.h>
main()
{
	int arr[]={12,23,78,98,67,56,45,19,65,9},key,i,flag=0;
	clrscr();
	printf("\nENTER A NUMBER: ");
	scanf("%d",&key);
	for(i=0;i<10;i++)
	{
		if(key==arr[i])
			flag=1;
	}
	if(flag==1)
		printf("\nTHE NUMBER %d EXISTS IN THE ARRAY",key);
	else
printf("\nTHE NUMBER %d DOES NOT EXIST IN THE ARRAY",key);
	getch();
}


Output







Quantitative Aptitude
Reasoning
Programming
Interview