Search This Blog

C program for linear searching and sorting

//coded by Z
#include<stdio.h>
void main()
{
  int z,b,l,u[20],flag=0;
  clrscr();
  printf("\nHow many no:s to be entered=\n");
  scanf("%d",&l);
  printf("\nEnter %d no:s\n\n",l);
for(z=0;z<l;z++)
{
scanf("%d",&u[z]);
}
printf("\nEnter number to be searched\n");
scanf("%d",&b);
for(z=0;z<=l;z++)


if(u[z]==b)
{
flag=1;
printf("\nthe searched no: %d is present at %d\n",b,z+1);
}
if (flag==0)
{
printf("\nsearched no:%d is not present ",b);
}
  getch();
}

No comments:

Post a Comment