100 Multiple Choice Questions In C Programming – Part 10
This collection of 100 Multiple Choice Questions and Answers (MCQs) In C Programming : Quizzes & Practice Tests with Answer focuses on “C Programming”.
1. What is the value of “y” in this code?
#include <stdio.h> void main() { int y = 5 * 9 / 3 + 9; }
A 24
B 3
C 2.68
D Depends on compiler
2. What is the value of “y” in this code?
#include <stdio.h> void main() { int y = 5.3 % 2; printf("The value of y is %d", y); }
A The value of y is 0,3
B The value of y is 1
C The value of y is 2,3
D Compilation error
3. What happens in the memory with the following code?
malloc(sizeof(int) * 25);
A This reserves memory for an integer of 25 bytes
B This reserves memory for an array of 25 integers
C This reserves memory for an array of 25 bytes
D This reserves memory for an array of 25 char
4. Dynamic memory allocation follows steps in a particular order, which one?
A malloc, use memory, check successful allocation, free
B malloc, use memory, free, check successful allocation
C free, check successful allocation, malloc, use memory
D malloc, check successful allocation, use memory, free
5. How to initialize a pointer to an array of 10 char?
A p = malloc (10);
B p = (char *) malloc(10,1);
C p = (char *) malloc (sizeof(10*char));
D p = (char *) malloc(10 * sizeof(char));
6. What is the output of the following C program?
#include <stdio.h> void main() { int x = 3; int y = ++x + x++ + --x; printf("Value of y is %d", y); }
A Value of y is 10
B Value of y is 13
C Value of y is 12
D Undefined value
7. Determine the priority of each operator (highest to lowest)?
A +, -, %, *, /
B %, +, -, *, /
C %, +, /, *, –
D %, *, /, +, –
8. Which of the following is not an arithmetic operation?
A x %= 10;
B x != 10;
C x /= 10;
D x *= 10;
9. Which of the following data types will generate an error on the modulo % operation?
A float
B int
C short
D char
10. Which of the following options are the basic arithmetic operators, i.e. the execution of the desired operation can be done using only this operator?
A +, -, *, /, %
B +, -, *, /
C +, -, %
D +, –