Skip to main content

Introduction to Programming MCQs with Answers

Practice important Introduction to Programming MCQs with answers and explanations.

Chapter: 12
Q181:
What is the correct syntax to initialize a character array with the string 'imran'?
A. char name[100] = 'imran';
B. char name[100] = { 'i', 'm', 'r', 'a', 'n' };
C. char name[100] = "imran";
D. char name = "imran";
Correct Answer: C
Chapter: 12
Q182:
Which search algorithm is more efficient for sorted arrays?
A. Linear search
B. Binary search
C. Sequential search
D. Hash search
Correct Answer: B
Chapter: 12
Q183:
How does binary search improve over linear search?
A. By reducing the array size by half each iteration
B. By comparing each element directly
C. By searching in a sorted order
D. By increasing the search space each iteration
Correct Answer: A
Chapter: 12
Q184:
What is the default mechanism of calling a function with arrays in C?
A. Call by value
B. Call by reference
C. Call by address
D. Call by pointer
Correct Answer: B
Chapter: 12
Q185:
In C, what is passed to a function when an array is used as a parameter?
A. A copy of the array
B. A pointer to the array
C. A reference to the array
D. A value from the array
Correct Answer: B
Chapter: 12
Q186:
What will be the result if you pass a single element of an array to a function?
A. Call by reference
B. Call by value
C. Call by address
D. Call by pointer
Correct Answer: B
Chapter: 12
Q187:
How do you declare a two-dimensional array in C?
A. int array[rows][columns];
B. int array[columns][rows];
C. int array[rows];
D. int array[columns];
Correct Answer: A
Chapter: 12
Q188:
What is the size of the array 'int num[3][5][7];'?
A. 105
B. 105 elements
C. 357
D. 3+5+7
Correct Answer: B
Chapter: 12
Q189:
How do you declare a function that reverses an array in C?
A. void reverse(char [], int);
B. void reverse(int [], int);
C. char reverse(int [], int);
D. int reverse(char [], int);
Correct Answer: A
Chapter: 13
Q190:
What is the primary use of an array?
A. To store elements of different types
B. To store elements in a tabular form
C. To store elements of similar types
D. To store data in a single variable
Correct Answer: C
Chapter: 13
Q191:
When dealing with a two-dimensional array, which structure is most commonly used for processing?
A. Recursive functions
B. Conditional statements
C. Loops
D. Exception handling
Correct Answer: C
Chapter: 13
Q192:
How do you access an element in a two-dimensional array?
A. a[column][row]
B. a[row][column]
C. a[column][row]
D. a[row][column]
Correct Answer: B
Chapter: 13
Q193:
What does the flowchart for inputting a two-dimensional array typically include?
A. A single loop for rows
B. Nested loops for rows and columns
C. A loop for columns only
D. A recursive function
Correct Answer: B
Chapter: 13
Q194:
In the provided example, how is the two-dimensional array a flipped for output?
A. By swapping columns
B. By swapping rows
C. By swapping elements randomly
D. By reversing row order while maintaining column order
Correct Answer: B
Chapter: 13
Q195:
What character is used to create a tab space in output formatting?
A. \n
B. \t
C. \r
D. \b
Correct Answer: B
Chapter: 13
Q196:
When transposing a square matrix, which elements remain unchanged?
A. Diagonal elements
B. Off-diagonal elements
C. All elements
D. None of the elements
Correct Answer: A
Chapter: 13
Q197:
What is a common mistake when swapping elements in matrix transposition?
A. Swapping the diagonal elements
B. Swapping rows and columns in all cases
C. Swapping elements without using a temporary variable
D. Not considering the matrix size
Correct Answer: C
Chapter: 13
Q198:
How do you handle transposing a matrix without altering diagonal elements?
A. Process the upper triangle only
B. Process the lower triangle only
C. Process the entire matrix
D. Avoid processing the diagonal elements
Correct Answer: A
Chapter: 13
Q199:
What is the main purpose of the transposeMatrix function?
A. To flip the matrix upside down
B. To interchange rows and columns
C. To sort the matrix in ascending order
D. To reverse the matrix elements
Correct Answer: B
Chapter: 13
Q200:
In the salary calculation problem, what should be done to identify 'unlucky' employees?
A. Compare their net salaries with those of lower salaries
B. Compare their gross salaries with those of lower salaries
C. Identify those with the highest gross salaries
D. Identify those with the highest net salaries
Correct Answer: A

Test Your Knowledge

Take a timed quiz on Introduction to Programming

🚀 Start Quiz Now