Thursday 9 January 2014

HOW TO PERFORM SEQUENCIAL SEARCH IN C

#include<stdio.h>
#include<conio.h>
void main()
{
  int i,n=10,k[10],x;
  clrscr();
  for(i=1;i<=n;i++)
    {

     printf("\n\tEnter value:-");
     scanf("%d",&k[i]);
    }
   printf("\n\n\tEnter No you want to search:-");
   scanf("%d",&x);
   i=1;
   while(k[i]!=x)
   {
    i=i+1;
    if(i==n+1)
    {
     printf("\n\n\t\tsuccessful search");
     getch();
     return;
    }
   }
     printf("\n\n\t\tunsuccessful search");
   getch();
}

No comments:

Post a Comment

How to change Background color by selecting color from Listview

activitymain.xml file::> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"     xm...