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

Programming Exercises

Implement a program to perform a linear search on an array.

Medium

Problem Statement

Implement a program to perform a linear search on an array.

Sample Input

int arr[] = {2, 4, 6, 8, 10}; and int key = 6;

Sample Output

Element found at index: 2

Limits

Time: 2s · Memory: 256 MB

Code Editor
00:00
#include <iostream> int main() { int arr[] = {2, 4, 6, 8, 10}; int key = 6; // Logic to perform linear search return 0; }
Log in or sign up to run or submit your code.Log inSign up
Input
int arr[] = {2, 4, 6, 8, 10}; and int key = 6;
Expected Output
Element found at index: 2