MCQ IN COMPUTER SCIENCE & ENGINEERING

COMPUTER SCIENCE AND ENGINEERING

DATA STRUCTURES

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
Arrays are declared using ____
A
Square brackets [ and ]
B
Parentheses ( and )
C
Quotation marks “ and “
D
Curly Braces { and }
Explanation: 

Detailed explanation-1: -Recall that we normally use the square brackets ‘[’ and ‘]’ to construct an ordinary array (e.g. see Example 5.7). Here, we initialize a cell array to contain three strings with different lengths. We say that the array contains three cells and each cell contains a string.

Detailed explanation-2: -Array in C are of two types; Single dimensional arrays and Multidimensional arrays. Single Dimensional Arrays: Single dimensional array or 1-D array is the simplest form of arrays that can be found in C. This type of array consists of elements of similar types and these elements can be accessed through their indices.

Detailed explanation-3: -Square brackets are used to index (access) elements in arrays and also Strings. Specifically lost[i] will evaluate to the ith item in the array named lost.

There is 1 question to complete.