Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Program written by Mst. Sima Khatun */
- //linear search
- #include<stdio.h>
- int main()
- {
- int n,i,item;
- printf("Enter how many number you want to assign to the array \n");
- scanf("%d",&n);
- int num[n];
- printf("enter %d number to the array \n",n);
- for(i=0;i<n;i++)
- {
- scanf("%d",&num[i]);
- }
- printf("enter the num you want to search from the array \n");
- scanf("%d",&item);
- for(i=0;i<n;i++)
- {
- if(item==num[i])
- {
- printf("item found in this list the index is %d \n",i);
- return 0;
- }
- }
- printf("item not found in this list\n");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement