-
What is an array in C?
A) A collection of variables of different data types
B) A collection of variables of the same data type
C) A mathematical function
D) A type of loop
Answer: B) A collection of variables of the same data type
-
How do you declare an integer array in C?
A) int myArray[];
B) int[] myArray;
C) array<int> myArray;
D) int myArray[10];
Answer: D) int myArray[10];
-
What is the index of the first element in a C array?
A) 0
B) 1
C) -1
D) 10
Answer: A) 0
-
What is the maximum number of elements that an array can hold in C?
A) 256
B) 1000
C) It depends on available memory
D) 10
Answer: C) It depends on available memory
-
How do you access the fifth element of an integer array named "myNumbers" in C?
A) myNumbers[4]
B) myNumbers[5]
C) myNumbers(5)
D) myNumbers.fifth
Answer: A) myNumbers[4]
-
Which C function is used to find the length of an array?
A) find_length()
B) count_array()
C) lengthof()
D) sizeof()
Answer: D) sizeof()
-
What happens if you try to access an array element with an index that is out of bounds?
A) It returns a null value
B) It crashes the program
C) It returns the last element
D) It returns an error code
Answer: B) It crashes the program
-
How do you initialize all elements of a float array named "prices" to 0 in C?
A) prices = 0;
B) set(prices, 0);
C) memset(prices, 0, sizeof(prices));
D) for (int i = 0; i < sizeof(prices); i++) prices[i] = 0;
Answer: C) memset(prices, 0, sizeof(prices));
-
Which real-life scenario best illustrates the use of a one-dimensional array?
A) Managing a 2D chessboard
B) Storing a list of students and their grades
C) Tracking daily temperatures in a city for a month
D) Representing a 3D model of a building
Answer: B) Storing a list of students and their grades
-
In a library's book catalog, how might a one-dimensional array be employed?
A) To store the number of pages in each book
B) To manage book titles, authors, and publication years
C) To represent the dimensions of bookshelves
D) To track the library's daily visitor count
Answer: B) To manage book titles, authors, and publication years
-
Which of the following is an example of using a one-dimensional array in financial management?
A) Keeping track of employees' work hours
B) Storing a list of company office locations
C) Managing monthly expenses for a household
D) Calculating the average temperature in a city
Answer: C) Managing monthly expenses for a household
-
How might a one-dimensional array be applied in sports statistics?
A) Recording player names and jersey numbers
B) Representing a soccer field with coordinates
C) Storing historical weather data for games
D) Tracking the number of goals scored by each player
Answer: D) Tracking the number of goals scored by each player
-
In a music player application, which scenario could involve using a one-dimensional array?
A) Storing a playlist of songs and their durations
B) Managing a list of user login credentials
C) Representing a 3D visualization of music notes
D) Tracking the weather during a concert
Answer: A) Storing a playlist of songs and their durations
-
What is a practical use case for a one-dimensional array in a supermarket's inventory system?
A) Keeping track of customer purchase history
B) Representing the layout of store aisles
C) Storing product prices and quantities in stock
D) Managing employee work schedules
Answer: C) Storing product prices and quantities in stock
-
How can a one-dimensional array be applied in the context of a car rental agency?
A) Recording customer contact information
B) Managing reservations for various car models
C) Storing GPS coordinates for delivery vehicles
D) Tracking daily fuel consumption for the fleet
Answer: B) Managing reservations for various car models
-
In a survey conducted by a marketing research company, where might a one-dimensional array be utilized?
A) To store the survey questions and answer choices
B) To represent a 2D map of survey respondent locations
C) Storing data on employees' job roles and responsibilities
D) Tracking the daily stock prices of various companies
Answer: A) To store the survey questions and answer choices
-
What is a 2-dimensional array in C?
A) A collection of integers
B) An array with two elements
C) An array of arrays
D) An array of characters
Answer: C) An array of arrays
-
How do you declare a 2-dimensional integer array in C with 3 rows and 4 columns?
A) int myArray[3, 4];
B) int myArray[3][4];
C) int myArray[4][3];
D) int myArray[12];
Answer: B) int myArray[3][4];
-
What is the maximum number of indices required to access an element in a 2-dimensional array with dimensions [5][6]?
A) 2
B) 3
C) 5
D) 6
Answer: A) 2
-
How do you access an element at the third row and second column of a 2-dimensional array named "matrix" in C?
A) matrix[2, 1]
B) matrix[1, 2]
C) matrix[3][2]
D) matrix[2][3]
Answer: C) matrix[3][2]
-
What is the size of a 2-dimensional character array declared as char grid[4][5] in C?
A) 4
B) 5
C) 9
D) 20
Answer: D) 20
-
How can you initialize a 2-dimensional integer array in C when declaring it?
A) int myArray[][] = {{1, 2}, {3, 4}};
B) int myArray[][] = {1, 2, 3, 4};
C) int myArray[2][2] = {{1, 2}, {3, 4}};
D) int myArray[2][2] = {1, 2, 3, 4};
Answer: C) int myArray[2][2] = {{1, 2}, {3, 4}};
-
What is the primary use of a 2-dimensional array in C?
A) To store a list of characters
B) To represent a matrix or a table of data
C) To create a dynamic data structure
D) To store a single value
Answer: B) To represent a matrix or a table of data
-
How do you iterate through all elements of a 2-dimensional array in C using nested loops?
A) You can't iterate through all elements of a 2-dimensional array
B) Using a single loop
C) Using two nested loops
D) Using three nested loops
Answer: C) Using two nested loops
-
What is linear search in C?
A) A search algorithm that only works on sorted arrays
B) A search algorithm that divides the array into two halves
C) A search algorithm that compares each element with the target element one by one
D) A search algorithm that uses a binary tree structure
Answer: C) A search algorithm that compares each element with the target element one by one
-
Which of the following statements about linear search is true?
A) Linear search is the most efficient search algorithm for large arrays.
B) Linear search is also known as binary search.
C) Linear search has a time complexity of O(log n) in the worst case.
D) Linear search has a time complexity of O(n) in the worst case.
Answer: D) Linear search has a time complexity of O(n) in the worst case.
-
What is binary search in C?
A) A search algorithm that works only on arrays of even length
B) A search algorithm that compares each element with the target element one by one
C) A search algorithm that divides the array into two halves and narrows down the search
D) A search algorithm that uses a hash table to store elements
Answer: C) A search algorithm that divides the array into two halves and narrows down the search
-
What is the time complexity of binary search in the worst case?
A) O(1)
B) O(n)
C) O(log n)
D) O(n^2)
Answer: C) O(log n)
-
Which search algorithm is more efficient for a sorted array, linear search, or binary search?
A) Linear search
B) Binary search
C) Both have the same efficiency
D) It depends on the size of the array
Answer: B) Binary search
-
In linear search, where does the search process stop if the target element is found?
A) At the beginning of the array
B) In the middle of the array
C) At the end of the array
D) After comparing all elements in the array
Answer: D) After comparing all elements in the array
-
Which search algorithm requires the array to be sorted in ascending or descending order?
A) Linear search
B) Binary search
C) Both linear and binary search
D) Neither linear nor binary search
Answer: B) Binary search
-
What is the primary advantage of binary search over linear search?
A) Binary search is easier to implement.
B) Binary search works on unsorted arrays.
C) Binary search has a faster average-case time complexity.
D) Binary search requires less memory.
Answer: C) Binary search has a faster average-case time complexity.
-
What is the purpose of sorting an array in C?
A) To create a copy of the array
B) To rearrange the elements in ascending or descending order
C) To remove all duplicate elements from the array
D) To resize the array
Answer: B) To rearrange the elements in ascending or descending order
-
Which of the following is NOT a commonly used sorting algorithm in C?
A) Quick Sort
B) Merge Sort
C) Bubble Sort
D) Split Sort
Answer: D) Split Sort
-
What is the time complexity of the Bubble Sort algorithm in the worst case?
A) O(1)
B) O(n)
C) O(n^2)
D) O(log n)
Answer: C) O(n^2)
-
Which sorting algorithm is known for its best-case time complexity of O(n) when the array is nearly sorted?
A) Quick Sort
B) Merge Sort
C) Bubble Sort
D) Insertion Sort
Answer: D) Insertion Sort
-
In which order does the Selection Sort algorithm sort an array in C?
A) Ascending order
B) Descending order
C) Random order
D) Selection Sort does not guarantee a specific order
Answer: A) Ascending order
-
What is the stable sorting algorithm in C?
A) Quick Sort
B) Merge Sort
C) Bubble Sort
D) Heap Sort
Answer: B) Merge Sort
-
Which sorting algorithm is not suitable for large datasets due to its quadratic time complexity?
A) Quick Sort
B) Merge Sort
C) Bubble Sort
D) Heap Sort
Answer: C) Bubble Sort
-
What is the primary advantage of using the Quick Sort algorithm over other sorting algorithms?
A) Quick Sort always performs in O(n) time.
B) Quick Sort is a stable sorting algorithm.
C) Quick Sort has a small constant factor and generally performs faster in practice.
D) Quick Sort can sort linked lists efficiently.
Answer: C) Quick Sort has a small constant factor and generally performs faster in practice.
-
How do you perform matrix addition in C?
A) Use the "+" operator between two matrices
B) Use the "-" operator between two matrices
C) Use the "*" operator between two matrices
D) Use a loop to add corresponding elements of two matrices
Answer: D) Use a loop to add corresponding elements of two matrices
-
In matrix addition, what is the requirement for the dimensions of the matrices being added?
A) They must have the same number of rows and the same number of columns
B) They must have a different number of rows and the same number of columns
C) They must have the same number of rows and a different number of columns
D) There are no specific requirements on dimensions
Answer: A) They must have the same number of rows and the same number of columns
-
What is the result of adding two matrices with dimensions [3][3] and [3][3]?
A) [6][6]
B) [3][3]
C) [9][9]
D) It's not possible to add these matrices
Answer: B) [3][3]
-
How do you perform matrix multiplication in C?
A) Use the "+" operator between two matrices
B) Use the "-" operator between two matrices
C) Use the "*" operator between two matrices
D) Use a loop to multiply corresponding elements of two matrices
Answer: D) Use a loop to multiply corresponding elements of two matrices
-
In matrix multiplication, what is the requirement for the number of columns in the first matrix and the number of rows in the second matrix?
A) They must be the same
B) The number of columns in the first matrix must be equal to the number of rows in the second matrix
C) The number of rows in the first matrix must be equal to the number of columns in the second matrix
D) There are no specific requirements on dimensions
Answer: B) The number of columns in the first matrix must be equal to the number of rows in the second matrix
-
What is the result of multiplying two matrices with dimensions [3][2] and [2][4]?
A) [3][4]
B) [2][2]
C) [3][3]
D) [2][4]
Answer: A) [3][4]
-
What is the identity matrix?
A) A matrix with all elements equal to 1
B) A matrix with all elements equal to 0
C) A square matrix with 1's on the main diagonal and 0's elsewhere
D) A square matrix with 0's on the main diagonal and 1's elsewhere
Answer: C) A square matrix with 1's on the main diagonal and 0's elsewhere
-
In matrix multiplication, what is the result of multiplying any matrix by the identity matrix?
A) The original matrix remains unchanged
B) The original matrix becomes all zeros
C) The original matrix becomes the identity matrix
D) It's not possible to multiply any matrix by the identity matrix
Answer: A) The original matrix remains unchanged
-
What is the diagonal of a matrix?
A) The top-left element of the matrix
B) The main diagonal running from the top-left to the bottom-right
C) The bottom-right element of the matrix
D) The sum of all elements in the matrix
Answer: B) The main diagonal running from the top-left to the bottom-right
-
How do you access the elements on the main diagonal of a matrix in C?
A) Using a loop to iterate through rows and columns
B) Using the square brackets notation with the row and column indices
C) Using the "@" symbol before the element name
D) It's not possible to access the main diagonal directly
Answer: B) Using the square brackets notation with the row and column indices