Problem solving through programming (18escs01)


Download 215.92 Kb.
bet1/4
Sana16.06.2023
Hajmi215.92 Kb.
#1502284
  1   2   3   4
Bog'liq
Module 3 C program

PROBLEM SOLVING THROUGH PROGRAMMING (18ESCS01)


1
UNIT-3: ARRAYS & STRINGS

ARRAYS AND STRINGS

  • ARRAYS
  • DECLARATION OF ARRAYS
  • INITIALIZATION OF ARRAYS
  • ONE-DIMENTIONAL & TWO-DIMENTIONAL ARRAYS
  • STRINGS
  • STRING OPERATIONS
  • STRING ARRAYS
  • SIMPLE OPERATIONS – SORTING & SEARCHING –

  • MATRIX OPERATIONS

2

ARRAYS

  • Array is a data structure that can store a fixed-size sequential collection of elements of the same type.
  • An array is defined as finite ordered collection of homogenous data (of same type), stored in contiguous memory locations.
  • The lowest address corresponds to the first element and the highest address to the last element.
  • Examples where arrays are applicable:
    • Used to store list of Employee or Student names.
    • Used to store marks of students,
    • Or to store list of numbers or characters etc.

3

DECLARATION OF ARRAYS

  • General form of array declaration is:
  • int -> is the data type,

  • arr ->is the name of the array and
    10 -> is the size of array [0 to size – 1]. It means
    array ’arr’ can only contain 10 elements of int type.

data-type array_name[array_size];
/* Example of array declaration */ int arr[10];

INITIALIZATION OF ARRAYS

  • We can initialize an array in ‘C’ either one by one or using a single statement as:
  • The number of values between braces { } cannot be larger than the number of elements that we declare for the array between square brackets [ ].

int a[5] = {10, 20, 30, 40, 50};
float balance[5] = {1000.0, 2.0, 3.4, 7.0, 50.0};

Download 215.92 Kb.

Do'stlaringiz bilan baham:
  1   2   3   4




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling