From 85020eea5faf69972a8e685b7b4be80abec052c7 Mon Sep 17 00:00:00 2001 From: Krishna Vedala Date: Thu, 28 May 2020 20:33:25 -0400 Subject: [PATCH] change error return value for function --- search/interpolation_search.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/search/interpolation_search.cpp b/search/interpolation_search.cpp index e12dbd157..4339dc366 100644 --- a/search/interpolation_search.cpp +++ b/search/interpolation_search.cpp @@ -30,7 +30,7 @@ int interpolation_search(int arr[], int value, int len) { if (arr[low] == value) return low; - return 0; + return -1; } /** main function */ @@ -51,7 +51,7 @@ int main() { re = interpolation_search(array, value, n); - if (re == 0) + if (re == -1) std::cout << "Entered value is not in the array" << std::endl; else std::cout << "The value is at the position " << re << std::endl;