diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..dce5ccd --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,20 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + + { + "name": "(Windows) Launch", + "type": "cppvsdbg", + "request": "launch", + "program": "enter program name, for example ${workspaceFolder}/a.exe", + "args": [], + "stopAtEntry": false, + "cwd": "${fileDirname}", + "environment": [], + "console": "externalTerminal" + } + ] +} \ No newline at end of file diff --git a/C++/Algorithm/Searching/binarySearchIterative.cpp b/C++/Algorithm/Searching/binarySearchIterative.cpp index c3b62b8..c073506 100644 --- a/C++/Algorithm/Searching/binarySearchIterative.cpp +++ b/C++/Algorithm/Searching/binarySearchIterative.cpp @@ -31,19 +31,18 @@ int binarysearch(vector < int > & arr, int ele) { } return -1; } - -int main() { - vector arr{ 2, 3, 5, 10, 35, 40 }; //sorted array - - int element = 10; // element to find - - int result = binarysearch(arr, element); - - if (result == -1) { // if element not present in array. - cout << "Element is not present in array"; - } else { - cout << "Element is present at index " << result; +int main() +{ + vector arr{2,3,5,10,35,40}; //sorted array + int element=10; //element to find + int result= binarysearch(arr,element); + if(result==-1) //if element is not present + { + cout<<"Element is not present in array."; } - - return 0; -} + else + { + cout<<"Element is present at index-"<