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

Most importance question with Answers in C++

1. Write the shorts notes on Garbage collection. Ans.  Garbage collection in C++ isn't native to the language; it relies on manual memory management using constructs like new and delete . However, some third-party libraries or smart pointers like std::shared_ptr and std::unique_ptr offer automated memory management. C++11 introduced smart pointers, reducing manual memory handling but lacking the automatic garbage collection found in languages like Java or Python. 2. What is multiple heritance? Ans. Multiple inheritance in C++ enables a class to inherit attributes and behaviors from more than one base class. It allows a derived class to access features from multiple parent classes, fostering complex class hierarchies but potentially causing issues like the diamond problem due to ambiguous member access. 3. What do you mean by operator overloading ? Ans. Operator overloading in C++ allows defining custom behaviors for operators like +, -, *, etc., for user-defined types. It enable

Course Name: Operating System[Objective QUESTION]

  Course Code: BCA-402 Course Name: Operating System UNIT-I: Introduction What is an operating system? a) A hardware component b) A system software that manages hardware and software resources c) An application software d) A programming language Answer: b) A system software that manages hardware and software resources Which of the following is a characteristic of simple batch systems? a) Real-time processing b) Interactive processing c) Jobs are processed in batches without user interaction d) Distributed processing Answer: c) Jobs are processed in batches without user interaction Multi-programmed batch systems are designed to: a) Handle one task at a time b) Improve CPU utilization by running multiple programs simultaneously c) Execute programs in a sequential manner d) Only manage system files Answer: b) Improve CPU utilization by running multiple programs simultaneously Time-sharing systems are characterized by: a) Batch processing b) Real-time processing c) Allowing multiple users