πŸ“Š C Programming
Q. Which of the following is not possible statically in C language?
  • (A) Jagged Array
  • (B) Rectangular Array
  • (C) Cuboidal Array
  • (D) Multidimensional Array
πŸ’¬ Discuss
βœ… Correct Answer: (A) Jagged Array

Explanation:

The correct answer is: (A) Jagged Array

Explanation:

In C language, array dimensions and sizes must be known at compile time for static allocation.

Let’s look at the options:

(A) Jagged Array – ❌ Not possible statically

  • A jagged array (also known as an "array of arrays" where each sub-array can have different lengths) is not possible statically in C.
  • C supports arrays of pointers to achieve jagged arrays dynamically, but you cannot declare a jagged array statically since each row would need to have a different size, and static arrays in C require fixed dimensions.

Example (dynamic jagged array):

int *arr[3];
arr[0] = malloc(2 * sizeof(int)); // 2 elements
arr[1] = malloc(4 * sizeof(int)); // 4 elements
arr[2] = malloc(3 * sizeof(int)); // 3 elements

(B) Rectangular Array – βœ… Possible statically

  • A typical 2D array with the same number of columns in each row.
int arr[3][4]; // 3 rows, 4 columns

(C) Cuboidal Array – βœ… Possible statically

  • A 3D array (same size for all dimensions).
int arr[3][4][5]; // 3 layers of 4x5

(D) Multidimensional Array – βœ… Possible statically

  • General term for arrays with 2 or more dimensions.
  • C supports statically declared multidimensional arrays:
int arr[2][3][4]; // 3D

Final Answer: (A) Jagged Array

Explanation by: Mr. Dubey

The correct answer is: (A) Jagged Array

Explanation:

In C language, array dimensions and sizes must be known at compile time for static allocation.

Let’s look at the options:

(A) Jagged Array – ❌ Not possible statically

  • A jagged array (also known as an "array of arrays" where each sub-array can have different lengths) is not possible statically in C.
  • C supports arrays of pointers to achieve jagged arrays dynamically, but you cannot declare a jagged array statically since each row would need to have a different size, and static arrays in C require fixed dimensions.

Example (dynamic jagged array):

int *arr[3];
arr[0] = malloc(2 * sizeof(int)); // 2 elements
arr[1] = malloc(4 * sizeof(int)); // 4 elements
arr[2] = malloc(3 * sizeof(int)); // 3 elements

(B) Rectangular Array – βœ… Possible statically

  • A typical 2D array with the same number of columns in each row.
int arr[3][4]; // 3 rows, 4 columns

(C) Cuboidal Array – βœ… Possible statically

  • A 3D array (same size for all dimensions).
int arr[3][4][5]; // 3 layers of 4x5

(D) Multidimensional Array – βœ… Possible statically

  • General term for arrays with 2 or more dimensions.
  • C supports statically declared multidimensional arrays:
int arr[2][3][4]; // 3D

Final Answer: (A) Jagged Array

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
360
Total Visits
πŸ“½οΈ
4 y ago
Published
πŸŽ–οΈ
Geetam
Publisher
πŸ“ˆ
80%
Success Rate