İnfografik
← Ünite 5
Computer Programming 1

Ünite 5: Chapter 5: C Arrays

Fixed Array Execution Size in C
Standard arrays in C possess a rigid design where their size cannot be changed during the execution of the program once defined. This static memory characteristic requires developers to estimate maximum storage needs beforehand or rely on dynamic memory allocation techniques.
Zero-Based Indexing Convention
In the C programming language, array indexing strictly begins at position zero. For a 5-element array named 'ar', the valid positions range from ar[0] up to ar[4], meaning the maximum subscript is always one less than the total number of elements.
Automatic Zero Padding for Partial Initializers
When an array is defined with a specific size and initialized with fewer values than requested, C does not leave the remaining spaces undefined. The compiler automatically initializes all remaining rightmost elements to zero.
Implicit Array Size Determination
If a programmer declares an array without specifying the number inside the square brackets but provides an explicit initializer list—such as int ar[]={-2, 0, 45};—the C compiler automatically sets the size of the array to 3.

Anahtar Kavramlar

ArrayA data structure consisting of a group of consecutive memory locations that store related data items of the same type under a single name. For example, int ar[5]; defines an array that holds five integer values.
Subscript / IndexThe position number enclosed in square brackets used to access a specific element within an array. For instance, in ar[1], the number 1 is the subscript representing the second element.
Contiguous MemoryA memory allocation layout where elements are stored sequentially right next to each other in RAM. Arrays use contiguous memory locations to ensure efficient data access.
Array DefinitionThe declaration process where a programmer specifies the data type, array name, and number of elements. Syntax requires the format arType arName[numberOfElements].
Array InitializationThe process of assigning initial values to array elements at the time of declaration using curly braces. For example, int ar[3]={-2, 0, 45}; initializes a three-element array.
Call-by-ReferenceThe mechanism by which arrays are inherently passed to functions in C, where the array name evaluates to the memory address of the first element rather than copying all data.
Bubble SortA fundamental sorting algorithm that makes multiple passes over an array, comparing successive pairs of elements and swapping them if they are out of order.
Multiple Subscripted ArrayAn array with two or more subscripts that represents tabular data structures like matrices with rows and columns, such as int ar[3][2].
Syntax ErrorA compilation error that occurs when code violates the grammatical rules of the C language, such as providing more initializers than the declared array size.
Pass-by-ValueThe mechanism used when passing individual array elements (e.g., ar[1]) to functions, where a copy of the element's value is passed rather than its memory reference.

Diğer Önemli Bilgiler

Array Name as Memory Pointer

When passing an array to a function in C, writing just the array name without square brackets passes the memory address of the first element. This makes arrays inherently behave as call-by-reference parameters.

Iterative Pairwise Comparison in Sorting

Sorting algorithms like Bubble Sort operate by making successive passes over the array data. They compare adjacent pairs of elements and execute element swapping if they are found in decreasing order when an increasing sequence is desired.

Matrix Representation in Multi-dimensional Arrays

Multiple subscripted arrays in C, such as int ar[3][2], allow programmers to represent two-dimensional tables containing rows and columns. Elements can be accessed using double subscripts like ar[2][1].

Sınavda Dikkat Et

  • Unutmayin ki C dilindeki standart dizilerin boyutu program calisirken (execution sirasinda) degistirilemez; bu nedenle sinavda dinamik boyut degisikligi iddialarina dikkat edin.
  • Dizi tanimlamalarinda (orn: int ar[5];) boyut belirtilmezse ve ilk deger listesi verilirse, dizinin boyutu listedeki eleman sayisi kadar olur.
  • Eksik ilk deger (initializer) verildiginde sagdaki elemanlarin otomatik olarak 0'a esitlendigini sinav sorulari icin mutlaka aklinizda tutun.
  • Fazla ilk deger verilmesinin calisma zamani hatasi degil, bir derleme (syntax) hatasi oldugunu unutmayin.
  • Fonksiyonlara dizi gecirilirken koseeli parantez kullanilmadigina ve dizilerin dogasi geregi 'call-by-reference' (referansa gore) aktarildigina dikkat edin.
  • Bireysel dizi elemanlarinin (orn: ar[2]) ise fonksiyonlara tum diziden farkli olarak 'call-by-value' (deere gore) gectigini karistirmayin.
  • Cok boyutlu (multiple subscripted) dizilerde baslangicta deger atanmayan elemanlarin otomatik olarak sifir oldugunu hatirlayin.