linear search in c

linear search in c

Page 1 of 1

1 Replies - 811 Views - Last Post: 07 December 2010 - 09:14 PM Rate Topic: -----

#1 Guest_Guest*


Reputation:

linear search in c

Posted 07 December 2010 - 09:12 PM

#include<stdio.h>
int main(){
int a[10],i,n,m,c=0;
printf("Enter the size of an array");
scanf("%d",&n);
printf("\nEnter the elements of the array");
for(i=0;i<=n-1;i++){
scanf("%d",&a[i]);
}
printf("\nThe elements of an array are");
for(i=0;i<=n-1;i++){
printf(" %d",a[i]);
}
printf("\nEnter the number to be search");
scanf("%d",&m);
for(i=0;i<=n-1;i++){
if(a[i]==m){
c=1;
break;
}
}
if(c==0)
printf("\nThe number is not in the list");
else
printf("\nThe number is found");
return 0;
}


This post has been edited by macosxnerd101: 07 December 2010 - 09:14 PM
Reason for edit:: Please use code tags


Is This A Good Question/Topic? 0

Replies To: linear search in c

#2 macosxnerd101  Icon User is offline

  • Self-Trained Economist
  • member icon




Reputation: 10185
  • View blog
  • Posts: 37,603
  • Joined: 27-December 08

Re: linear search in c

Posted 07 December 2010 - 09:14 PM

What is your question? What problems or errors are you encountering?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1