Practice Real Company Assessment Patterns • Latest 2025–2026 Mock Tests

Programming Exercises

Create a program to implement binary search on a sorted array.

Hard

Problem Statement

Create a program to implement binary search on a sorted array.

Sample Input

arr = {1, 2, 3, 4, 5}, target = 3

Sample Output

Element found at index 2

Limits

Time: 2s · Memory: 256 MB

Code Editor
00:00
#include <stdio.h> int binarySearch(int arr[], int size, int target); int main() { int arr[] = {1, 2, 3, 4, 5}; int target = 3; // Logic to perform binary search return 0; }
Log in or sign up to run or submit your code.Log inSign up
Input
arr = {1, 2, 3, 4, 5}, target = 3
Expected Output
Element found at index 2