From 8326e2f557e919c0fb1d115c3f572f96aa7e2224 Mon Sep 17 00:00:00 2001 From: Manisha Chaturvedi <68684840+manisha-hub@users.noreply.github.com> Date: Sat, 3 Oct 2020 00:40:49 +0530 Subject: [PATCH] Updated to a general program. I have converted your code to a general one, so now it can be used to any integer array of any size given by the user. I hope you will merge it which will definitely going to help others also. --- Search/LinearSearch/C/linear_search.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/Search/LinearSearch/C/linear_search.c b/Search/LinearSearch/C/linear_search.c index 02ee11ed..b7c5f3b4 100644 --- a/Search/LinearSearch/C/linear_search.c +++ b/Search/LinearSearch/C/linear_search.c @@ -14,10 +14,17 @@ int search(int arr[], int n, int key) int main() { - int arr[] = {4, 10, 8, 25, 13, 89, 45, 12, 78, 11}; - int key = 78; + int size; + printf("Enter the size of the array\n"); + scanf("%d\n",&size); + int arr[size],key; int n = sizeof(arr) / sizeof(int); - + printf("Enter the elememts of the array\n"); + for(int i=0;i