Quiz For C
Quiz For C
● A) int a;
● B) int: a;
● C) int = a;
● D) a int;
Answer: A) int a;
Answer: B) 4 bytes
● A) 5
● B) 6
● C) Undefined
● D) Compilation error
Answer: A) 5
Answer: C) scanf()
● A) 15
● B) 20
● C) 25
● D) 30
Answer: C) 25
Answer: B) 1st_variable
Answer: B) malloc()
● A) A is greater
● B) B is greater
● C) Compilation error
● D) No output
Answer: B) B is greater
Answer: C) break
15. Which of the following is the correct format specifier for printing a floating-point
number in C?
● A) %d
● B) %f
● C) %c
● D) %lf
Answer: B) %f
● A) 0
● B) 1
● C) 5
● D) Compilation error
Answer: B) 1
● A) 5
● B) 10
● C) 15
● D) 20
Answer: C) 15
● A) Equal
● B) Not Equal
● C) Compilation error
● D) No output
Answer: A) Equal
Answer: A) It ends the function and returns control to the calling function
26. Which of the following statements is used to skip the current iteration of a loop?
● A) break
● B) continue
● C) goto
● D) return
Answer: B) continue
28. What will be the value of b after executing the following code?
int a = 5;
int b = ++a;
● A) 5
● B) 6
● C) 7
● D) Compilation error
Answer: B) 6
● A) 3.33
● B) 3
● C) 10
● D) Compilation error
Answer: B) 3
Answer: B) #define
33. What is the output of the following code?
int a = 5;
int b = a * 2;
printf("%d", b);
● A) 10
● B) 5
● C) 15
● D) Compilation error
Answer: A) 10
Answer: D) real
35. What does the fopen() function return if it fails to open a file?
● A) NULL
● B) 0
● C) 1
● D) The error code
Answer: A) NULL
Answer: B) fclose()
Answer: A) 2
● A) 65
● B) 97
● C) A
● D) Compilation error
Answer: A) 65
● A) 1
● B) 2
● C) 3
● D) 4
Answer: C) 3
Answer: D) float[]
● A) 0
● B) 1
● C) 5
● D) Compilation error
Answer: B) 1
Answer: A) const
● A) 3
● B) 3.33
● C) 3.000000
● D) Compilation error
Answer: C) 3.333333
46. What is the output of this code?
int a = 10;
int b = 5;
if (a < b) {
printf("A is smaller");
} else {
printf("B is smaller");
}
● A) A is smaller
● B) B is smaller
● C) Compilation error
● D) No output
Answer: B) B is smaller
Answer: A) int
● A) One
● B) One Two
● C) One Two Three
● D) One Two Three Default
● A) 2
● B) 4
● C) 0
● D) Compilation error
Answer: A) 2
Answer: C) &
53. What is the maximum value that can be stored in an unsigned char variable?
● A) 127
● B) 128
● C) 255
● D) 256
Answer: C) 255
● A) 0
● B) 1
● C) 3
● D) Compilation error
Answer: A) 0
Answer: D) repeat-until
58. What is the correct way to declare a function that returns a pointer in C?
● A) int* function();
● B) *int function();
● C) int function*();
● D) function int*();
Answer: A) int* function();
Answer: D) global
● A) 2
● B) 3
● C) 4
● D) 5
Answer: C) 4
Answer: B) struct
Answer: B) fwrite()
64. Which of the following is the correct syntax to pass an array as a parameter to a
function in C?
● A) func(int arr[]);
● B) func(int arr);
● C) func(int *arr[]);
● D) func(int &arr[]);
● A) 10
● B) 20
● C) 30
● D) 50
Answer: C) 30
68. Which of the following correctly declares a variable to hold the address of a
pointer to an integer?
● A) int *ptr;
● B) int **ptr;
● C) int &ptr;
● D) int ptr;
70. Which of the following operators is used to access members of a structure using a
pointer?
● A) .
● B) ->
● C) *
● D) &
Answer: B) ->
● A) 10 15
● B) 15 10
● C) 0 0
● D) Compilation error
Answer: B) 15 10
Answer: B) malloc()
● A) H
● B) e
● C) l
● D) Compilation error
Answer: B) e
Answer: B) calloc() initializes the allocated memory to zero, malloc() does not
77. What will the following code output?
int x = 0;
if(x) {
printf("True");
} else {
printf("False");
}
● A) True
● B) False
● C) 0
● D) Compilation error
Answer: B) False
● A) 15
● B) 16
● C) 14
● D) Compilation error
Answer: A) 15
Answer: C) typeof
81. Which keyword is used to declare a constant variable in C?
● A) constant
● B) const
● C) immutable
● D) static
Answer: B) const
Answer: B) break
Answer: A) int
● A) 1
● B) 2
● C) 3
● D) Compilation error
Answer: B) 2
86. Which of the following is the correct syntax for accessing a member of a structure
using a pointer to the structure?
● A) ptr.member
● B) ptr->member
● C) (*ptr).member
● D) Both B and C
● A) Yes
● B) No
● C) 3
● D) Compilation error
Answer: A) Yes
● A) W
● B) o
● C) ,
● D) Compilation error
Answer: A) W
90. Which function is used to allocate a block of memory in C and initialize it to zero?
● A) malloc()
● B) calloc()
● C) realloc()
● D) free()
Answer: B) calloc()
Answer: C) %o
● A) 3
● B) 10
● C) 1
● D) 0
Answer: C) 1
Answer: C) 6
95. Which of the following correctly assigns the memory address of variable x to
pointer p?
● A) int x = 5, p = x;
● B) int x = 5, *p = x;
● C) int x = 5, *p = &x;
● D) int x = 5, &p = x;
Answer: C) 8 bytes
97. Which operator is used to access the value at the address stored in a pointer?
● A) *
● B) &
● C) @
● D) %
Answer: A) *
● A) 5
● B) 10
● C) Compilation error
● D) Garbage value
Answer: B) 10
● A) 2.00
● B) 2.50
● C) 2.75
● D) 3.00
Answer: A) 2.00
A) auto
B) register
C) extern
D) public
Answer: D) `public`