Skip to content

A C program containing a function that performs a linear search on an integer array. It returns the 1-based index position of a target element or -1 if the element is not found.

License

Notifications You must be signed in to change notification settings

ShotsMan2/Array-Element-Index-Finder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Array Element Index Finder

This project implements a simple linear search algorithm in C encapsulated within a helper function.

⚙️ Logic

  1. Function: int Eleman_Index_Bul(int dizi[], int aranan)
  2. Input: An integer array and a target value.
  3. Process:
    • Iterates through the array indices ($0 \to N-1$).
    • Compares dizi[i] with aranan.
  4. Output:
    • If found: Returns i + 1 (1-based Rank).
    • If not found: Returns -1.

🚀 Example Output

Based on Question 1: Array: {1, 2, 5, 12, 20, 50, 4, 30} Target: 5

  • Index 0: 1 != 5
  • Index 1: 2 != 5
  • Index 2: 5 == 5 $\to$ Match!
  • Result: Returns 2 + 1 = 3.
--- Dizi Arama Programi ---
Dizi: {1, 2, 5, 12, 20, 50, 4, 30}
Aranan Sayi: 5
Sonuc: Aranan eleman 3. sirada bulundu.

About

A C program containing a function that performs a linear search on an integer array. It returns the 1-based index position of a target element or -1 if the element is not found.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages