السابق التالي
0 / 21
الوحدة النمطية DEMO-32-106DEMO-C-32

Linear Search

DEMO-C-32 • Programming in C

Browser-only practice

بيان المشكلة

Write a C program to perform a linear search on a 1D array. Input the size n, the array elements, and a target value key. If the key is present, print "FOUND at index i" (where i is the 0-based index of the first occurrence). If not found, print "NOT FOUND".

Example 1

Input:

5 10 20 30 40 50 30

Output:

FOUND at index 2

Example 2

Input:

5 10 20 30 40 50 99

Output:

NOT FOUND

قيود

1 <= n <= 100

تنسيق الإدخال

n, array, key

تنسيق الإخراج

Search result string

حالات اختبار نموذجية

Submit runs every public testcase in this browser. Results and code never leave this device.

العينة رقم 1
عينة ظاهرة
5
10 20 30 40 50
30
FOUND at index 2
30 is at index 2.
العينة رقم 2
عينة ظاهرة
5
10 20 30 40 50
99
NOT FOUND
99 is not in the list.
العينة رقم 3
عينة ظاهرة
6
5 10 5 20 5 30
5
FOUND at index 0
First occurrence of 5 is at index 0.

Web terminal

C, C++, Java, and Python run locally in a browser VM. No worker or visualizer is used.

Saved in this browser
إعدادات المحرر