Skip to main content

In c, Array objective question with option

1. What is an array in C?

a) A collection of similar data items stored in contiguous memory locations.

b) A collection of different data items stored in non-contiguous memory locations.

c) A collection of similar data items stored in non-contiguous memory locations.

d) A collection of different data items stored in contiguous memory locations.

Answer: a) A collection of similar data items stored in contiguous memory locations.


2.What is the syntax to declare an array in C?

a) dataType arrayName[arraySize];

b) dataType arraySize[arrayName];

c) arrayName[arraySize] dataType;

d) arraySize[arrayName] dataType;

Answer: a) dataType arrayName[arraySize];


3.How do you access the first element of an array in C?

a) arrayName[0];

b) arrayName[1];

c) arrayName[-1];

d) arrayName[first];

Answer: a) arrayName[0];


4.What is the index of the last element of an array in C?

a) arraySize;

b) arraySize - 1;

c) arraySize + 1;

d) arraySize * 2;

Answer: b) arraySize - 1;


5.Can you change the size of an array after it has been declared in C?

a) Yes, using the realloc() function.

b) Yes, using the resize() function.

c) No, the size of an array cannot be changed after it has been declared.

d) No, but you can declare a new array with a different size.

Answer: c) No, the size of an array cannot be changed after it has been declared.


6.How do you initialize an array in C?

a) int myArray[3] = [1, 2, 3];

b) int myArray[3] = {1, 2, 3};

c) int myArray = {1, 2, 3};

d) int myArray = [1, 2, 3];

Answer: b) int myArray[3] = {1, 2, 3};


7.What is the default value of an uninitialized array in C?

a) 0

b) 1

c) NULL

d) Undefined

Answer: d) Undefined


8.What is a two-dimensional array in C?

a) An array of integers.

b) An array of strings.

c) An array of arrays.

d) An array of structures.

Answer: c) An array of arrays.


9.What is the syntax for declaring a two-dimensional array in C?

a) dataType arrayName[rowSize][colSize];

b) dataType rowSize[colSize][arrayName];

c) dataType arrayName[colSize][rowSize];

d) dataType colSize[arrayName][rowSize];

Answer: a) dataType arrayName[rowSize][colSize];


10.How do you access an element in a two-dimensional array in C?

a) arrayName[rowIndex, colIndex];

b) arrayName[rowIndex][colIndex];

c) arrayName[colIndex, rowIndex];

d) arrayName[colIndex][rowIndex];

Answer: b) arrayName[rowIndex][colIndex];


11.What is a jagged array in C?

a) An array of arrays where each row has the same number of elements.

b) An array of arrays where each row can have a different number of elements.

c) An array of structures.

d) An array of pointers.

Answer: b) An array of arrays where each row can have a different number of elements


12.What is a 1D array in C?

a) An array with one element

b) An array with two elements

c) An array with multiple elements arranged in a single row

Answer: c) An array with multiple elements arranged in a single row


13.How do you declare a 1D array in C?

a) int arr[];

b) int arr[5];

c) int []arr;

Answer: b) int arr[5];


14.What is a 2D array in C?

a) An array with one element

b) An array with two elements

c) An array with multiple elements arranged in rows and columns

Answer: c) An array with multiple elements arranged in rows and columns


15.How do you declare a 2D array in C?

a) int arr[5];

b) int arr[][] = { {1, 2}, {3, 4} };

c) int arr[3][3];

Answer: c) int arr[3][3];


16.What is a multidimensional array in C?

a) An array with multiple elements arranged in a single row

b) An array with multiple elements arranged in rows and columns

c) An array with elements arranged in more than two dimensions

Answer: c) An array with elements arranged in more than two dimensions


17.How do you declare a 3D array in C?

a) int arr[3][3];

b) int arr[3][3][3];

c) int arr[][][];

Answer: b) int arr[3][3][3];


18.How do you access elements in a 2D array in C?

a) arr[i]

b) arr[i][j]

c) arr[i,j]

Answer: b) arr[i][j]


19.How do you access elements in a 3D array in C?

a) arr[i]

b) arr[i][j]

c) arr[i,j,k]

Answer: c) arr[i,j,k]

What is an array in C?

a) A variable that can store a single value

b) A collection of variables of the same type, stored in contiguous memory locations

c) A function that performs a specific task

Answer: b) A collection of variables of the same type, stored in contiguous memory locations


20.How do you declare an array in C?

a) array name;

b) data_type array_name;

c) data_type array_name[array_size];

Answer: c) data_type array_name[array_size];


21.What is the maximum number of elements that can be stored in an array in C?

a) 100

b) 1000

c) It depends on the amount of available memory

Answer: c) It depends on the amount of available memory


22.Can the size of an array be changed during runtime in C?

a) Yes

b) No

Answer: b) No


23.How do you access the elements of an array in C?

a) By specifying the index of the element in square brackets after the array name

b) By using a pointer to the array

c) By calling a function that returns the element at a specified index

Answer: a) By specifying the index of the element in square brackets after the array name


24.What is the index of the first element in an array in C?

a) 0

b) 1

c) -1

Answer: a) 0


25.What is the index of the last element in an array of size n in C?

a) n-1

b) n

c) n+1

Answer: a) n-1


26.How do you initialize the elements of an array in C?

a) By assigning values to each element individually

b) By using a loop to assign values to each element

c) By using an initializer list in the array declaration

Answer: c) By using an initializer list in the array declaration


27.What is the syntax for accessing a 2D array in C?

a) array_name[i]

b) array_name[i,j]

c) array_name[i][j]

Answer: c) array_name[i][j]


28.Can arrays be passed as arguments to functions in C?

a) Yes

b) No 

Answer; yes

Comments

Popular posts from this blog

VALUE OF TIME

Time is very precious.  We should not waste time.  Once time is lost, it is lost forever.  If you waste time, time will waste you. Money that has been spent can be recovered but not with time.  Time that once elapsed has passed and is over.  Almost everything in the world can be bought, but time lost cannot be bought.When a second has elapsed, that second moves from the present to the past.  If you have not made proper use of that which was in the present, then that second is wasted, it is destroyed and becomes the past.  No matter how much effort or distraction, that past cannot be brought back.If you want to achieve success in life, use your time properly.  take care of the present and Make full use of it. That's all Thank you ❤️

What is external storage class?

Ans . External variables are declared outside all functions,i.e. in the beginning of the program file. As all the functions will be defined after these variables declarations , so these variables are visible to all functions in a program file .

Meaning of accounting

  Meaning of accounting :  A ccounting is  the process of keeping track of an organization's financial transactions and records, and summarizing and communicating this information to relevant parties, such as investors ,creditors, and managers. It helps organizations to manage their finances effectively and make informed decisions about their business activities.