100 Multiple Choice Questions In C Programming – Part 8
This collection of 100 Multiple Choice Questions and Answers (MCQs) In C Programming : Quizzes & Practice Tests with Answer focuses on “C Programming”.
1. With which value should a pointer be initialized?
A 0
B NULL
C -1
D None of the above
[st_adsense]
2. According to the following statements, what is the output of “p2”?
int A = 5; int *p1 = &A; // p1 points to A int **p2 = &p1; // p2 points to p1
A The value of A
B The address of p1
C The address of A
D None of the above
3. The function tolower() defined in the C library works for ___?
A Ascii character set
B Ascii and utf-8 but not the EBSIDIC character set
C Unicode character set
D Any set of characters
4. What is the output of the code below considering the size of “short int” is 2, “char” is 1 and “int” is 4 bytes?
#include <stdio.h> int main() { short int a = 20; char b = 97; printf("%d, %d, %d\n", sizeof(a), sizeof(b), sizeof(b + a)); return 0; }
A 2, 1, 1
B 2, 1, 4
C 2, 1, 2
D 2, 2, 8
[st_adsense]
5. Which type conversion is NOT accepted?
A char –> int
B double –> char
C int –> char
D float –> char *
6. Which of the following will be the type of ‘res’?
res = (float)x * (int)y / (long)w * (double)z
A double
B float
C long
D int
7. Which of the following type-casting can be “wrapped”?
A char –> int
B int –> float
C int –> char
D char –> short
8. Which of the following type-casting is accepted in C?
A Implicit type conversion
B Explicit type conversion
C Both
D None of the above
[st_adsense]
9. When should you use type-casting?
A The value to be stored exceeds the maximum limit
B The value to be stored is not supported by this data type
C To reduce the memory used, according to the value
D All the answers are true
10. Which of the following codes creates an array of 5 integers?
A int arr(5);
B int *arr[5];
C int arr[4];
D int arr[5];