C Programming Language MCQ Exercise 229 Jan 2025 | 4 min read 1. When the C gets function is used, which of the following can cause problems?
Explanation: Option c is the correct answer. It can cause buffer overflow because the gets method will not check the limits of the input buffer. 2. Which of the following options describes the functions of the setjmp and longjmp functions in C?
Explanation: Option A is the correct answer. Setjmp saves the current state so that longjmp can use it later, which is a non-local goto in the protected environment. 3. Regarding structural padding in C, which of the following is true?
Explanation: Option b is the correct answer. Structural padding is used to ensure that the members of a structure align according to the alignment specifications of the platform. 4. Which of the following actions in C are negated?
Explanation: Option d is the correct answer. You can't increment an integer with a pointer. Multiplication doesn't work properly on pointers, but you can add, subtract, and compare integers. 5. What does it mean when the extend keyword is used for variable declaration in C programming?
Explanation: Option A is the correct answer. The extern keyword is used to declare a global variable declared in another file. It allows multiple files to access the same variable. 6. What is the effect of the sizeof(char) expression in C?
Explanation: Option b is the correct answer. The C standard states that a character can be only 1 byte, independent of the order. 7. Which of the following option represent a segmentation failure in C?
Explanation: Option d is the correct answer. Segmentation error occurs when a program tries to access memory for which it does not have access; it is usually occurs due to an invalid pointer specified. 8. Which of the following refers to the use of assert.h in C?
Explanation: Option b is the correct answer. Typically, the macro asserts in assert.h is used for debugging. If any condition fails in the c program, assert.h can be used to terminate the program. 9. What is the main function of C's inline keyword?
Explanation: Option b is the correct answer. The inline keyword tells the compiler to extend the inline function instead of calling the standard function. 10. What is the use of C #define directive?
Explanation: Option A is the correct answer. Programmers can use descriptive names for constants or functions instead of hard-coded values by creating macro definitions for them using the #define directive. Next TopicC-programming-language-mcq-exercise-3 |
1. Which of the following option describes Bubble Sort's comparison strategy? Compare and swap adjacent elements if needed. Compare and swap non-adjacent elements. Compare and swap with a pivot element. Compare with a mid-point element. Show AnswerWorkspace Explanation: The correct answer is option (a). When two adjacent elements are not in the correct...
2 min read
1. How many elements contain a 2D array, such as int mat[4][3]? 7 12 10 6 Show Answer Workspace Explanation: The correct answer is option (b). Here, the mat[4][3] array will have 4 rows and 3 columns, which sum up to 12 elements. 2. Apart from...
2 min read
1. What is the space complexity of the method for computing the nth Fibonacci number using dynamic programming? O(n^2) O(log n) O(1) O(n) Show Answer Workspace Explanation: The correct answer is option "c". Fibonacci numbers are often computed using a dynamic programming approach, where iously computed numbers are stored in an array...
3 min read
1. What is the main purpose of using the round-robin scheduling algorithm? To prioritize high-priority tasks To ent some processes from taking control of the CPU time and excluding other processes. To also reduces the time taken to complete the set goals. To fully utilize the CPU. Show Answer Workspace Explanation: The...
2 min read
1. In C, what is a two-dimensional array? An array of arrays A single column of elements A single row of elements None of the above Show Answer Workspace Explanation: The correct answer is option "a". A two-dimensional array in C can be visualized as a table with rows and columns...
3 min read
1. How can you free or delete the allocated memory for a 2D array in C programming? free(matrix); free(matrix[0]); for(int i=0; i<rows; i++) free(matrix[i]); free(matrix); for(int i=0; i<cols; i++) free(matrix[i]); free(matrix); Show Answer Workspace Explanation: The...
2 min read
1. Which of the following is the right way to pass a pointer to the function that accepts float as an argument and returns the int? int *fptr(float); int (*fptr)(float); int *(fptr(float)); int (*fptr(float)); Show Answer Workspace Explanation: The correct answer is b. The syntax for declaring a pointer to the function...
4 min read
1. What is the output of the following code? void increment(int *x) { *x = *x + 1; } int main() { int a = 10; increment(&a); printf("%d", a); return 0; } ...
4 min read
1. What is the output of the following Code? #include <stdio.h> int main() { for(int i = 1; i <= 5; i++) { for(int j = 1; j <= 9; j++) ...
4 min read
1. How to declare a 2D array for a matrix in C programming? int matrix[10, 10]; int matrix(10)(10); int matrix[10]; int matrix[10][10]; Show Answer Workspace Explanation: The correct answer is option (d). The right way to declare a 2d array is use to a matrix[10][10] to generate a 10X10...
2 min read
We request you to subscribe our newsletter for upcoming updates.
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India