MCS-011 Problem Solving and Programming

First year, Semester 1

Chapters

Newsletter

Array Declaration

Key Features of Arrays:

  • Definition: Arrays are data structures that store a group of elements of the same data type.
  • Naming: All elements share the same name, differentiated by an index.
  • Access: Elements can be accessed randomly using a numeric index.
  • Simplicity: Arrays are simple and have been used for decades, offering great utility.
  • ADT List: Frequently associated with the Abstract Data Type (ADT) list.


Array Declaration

Syntax: data-type array_name [constant-size];  where, Data-type: The type of elements stored and Constant-size: The number of elements.


Examples:

  1. int num[80];
  2. float farr[500];
  3. static int iarr[80];


Restrictions:

  1. Fixed Size: The storage amount must be specified at compile time
  2. Homogeneity: All elements in an array must be of the same data type.


Size Specification

Use symbolic constants for array sizes for easier modifications. Example:

#define SIZE 50

int arr[SIZE];

Report an issue

Reporting: Array Declaration (topic)

Related Posts