programming in c quiz
programming in c quiz
a) volatile
b) true
c) friend
d) export
Answer : a)
2. Which keyword is used to prevent any changes in the variable within a C program?
a) immutable
b) mutable
c) const
d) volatile
Answer : c)
3. The C-preprocessors are specified with _________ symbol.
a) #
b) $
c) ” ”
d) &
Answer:a)
4. In C language, FILE is of which data type?
a) int
b) char *
c) struct
d) None of the mentioned
Answer : c)
5. What is the sizeof(char) in a 32-bit C compiler?
a) 1 bit
b) 2 bits
c) 1 Byte
d) 2 Bytes
Answer : c)
6. What will be the output of the following C code on a 64 bit machine?
1. #include <stdio.h>
2. union Sti
3. {
4. int nu;
5. char m;
6. };
7. int main()
8. {
9. union Sti s;
10. printf("%d", sizeof(s));
11. return 0;
12. }
a) 8
b) 5
c) 9
d) 4
Answer: d
Explanation: Since the size of a union is the size of its maximum data type, here int
is the largest data type. Hence the size of the union is 4.
Output:
$ cc pgm7.c
$ a.out
4
7. What will be the final value of x in the following C code?
1. #include <stdio.h>
2. void main()
3. {
4. int x = 5 * 9 / 3 + 9;
5. }
a) 3.75
b) Depends on compiler
c) 24
d) 3
Answer: c
8. Comment on the following C statement.
n = 1;
printf("%d, %dn", 3*n, n++);
a) Output will be 3, 2
b) Output will be 3, 1
c) Output will be 6, 1
d) Output is compiler dependent
Answer: d
9. What will be the data type returned for the following C function?
1. #include <stdio.h>
2. int func()
3. {
4. return (double)(char)5.0;
5. }
a) char
b) int
c) double
d) multiple type-casting in return is illegal
Answer: b
10. Which option should be selected to work the following C expression?
string p = "HELLO";
Answer: b