100 Multiple Choice Questions In C Programming – Part 11
This collection of 100 Multiple Choice Questions and Answers (MCQs) In C Programming : Quizzes & Practice Tests with Answer focuses on “C Programming”.
1. We want to change the size of an array ‘Arr’ of integers, from 10 to 11 integers ?
A Arr = (int *) malloc(11* sizeof(int));
B Arr = (int *) malloc(11);
C Arr= (int *) realloc(T, 11* sizeof(int));
D Arr = (char *) realloc(11 * sizeof (int));
2. P points to an array of 10 integers, we want to free the memory it occupies. So how do we do it?
A P = NULL;
B *P = 0;
C free(P);
D free(*P);
[st_adsense]
3. What is the value of “z” in this code?
#include <stdio.h> int main() { int x = 10; double y = 5.6; int c; int z = x + y; printf("Value of z is %d", z); }
A Value of z is 10
B Value of z is 15
C Value of z is 15.6
D Value of z is 16
4. What is the value of “z” in this code?
#include <stdio.h> int main() { int x = 10, y = 5, w = 5; int d; int z = x == (y + w); printf("Value of z is %d", z); }
A Value of z is 5
B Value of z is 1
C Value of z is 10
D Syntax error
5. What is the output of the following C program?
#include <stdio.h> int main() { int a = 1, b = 0, c = 3; a > b ? printf("%d", c) : return c; }
A 1
B 3
C Runtime error
D Compilation error
6. What is the output of the following C program?
#include <stdio.h> void main() { int a = 1, c = 3; int b = a << 3; printf(" %d\n", b); }
A 8
B 1
C -724794438
D Compilation error
[st_adsense]
7. What is the output of the following C program?
#include <stdio.h> void main() { int a = 0, b = 2, c = 3; int x = a & b | c; printf("%d", x); }
A 2
B 3
C 0
D Depends on compiler
8. What is the output of the following C program?
#include <stdio.h> int main() { int a = 0, b = 0; if (a && (b = a + 10)) //do something ; ; }
A 10
B 0
C Depends on compiler
D Depends on the standard
[st_adsense]
9. What is the output of the following C program?
#include <stdio.h> int main() { int a = 1; if (a++ && (a == 1)) printf("OK\n"); else printf("KO\n"); }
A KO
B OK
C Depends on compiler
D Depends on the standard
10. Why is it called C++?
A Because it is the increment of the C language
B Because it is the C language plus the Javascript language
C Because it’s more elegant
D All the answers are true