WorksheetsC Programming Quiz
Total questions: 50
Worksheet time: 25mins
What will be the output of printf("%d", sizeof('A'));?
1
2
4
8
Which keyword is used to prevent modification of a variable?
static
const
volatile
register
What is the output of the code int a = 5; printf("%d", a++ + ++a);?
11
12
10
Undefined behavior
Which operator has the highest precedence in C?
*
++
()
[]
Which of the following is used to dynamically allocate memory in C?
alloc()
calloc()
malloc()
Both B and C
What does this code output? int a = 10; int b = a++ + ++a; printf("%d", b);
21
22
23
24
Which of the following is not a storage class in C?
auto
extern
volatile
static
What is the return type of malloc()?
int
void
void *
float
Which function is used to read a string with spaces?
scanf()
gets()
fgets()
getch()
Which is correct syntax for a function pointer?
int *func();
int (*func)();
*int func();
func int*();
Which header file is required for strlen()?
stdlib.h
string.h
stdio.h
ctype.h
Which format specifier is used to print an address?
%p
%x
%d
%u
Which of these is a correct 2D array declaration?
int arr[ ][3];
int arr[3][3];
int arr(3)(3);
int arr[];
Which loop is guaranteed to run at least once?
for
while
do-while
switch
How to access structure member with a pointer?
*ptr.member
ptr->member
ptr.member
&ptr.member
Size of integer pointer on 64-bit system?
2 bytes
4 bytes
8 bytes
Depends
Which is not a loop control structure?
break
continue
goto
switch
Correct way to declare function pointer?
int *fptr();
int (*fptr)();
(*fptr)int();
fptr() *int;
What does char str[] = "Hello"; printf("%c", *str); print?
H
e
o
l
Correct file opening mode to append?
"w"
"a"
"r"
"ra"
Which is not a valid pointer type?
void*
int*
function*
char*
Which function frees memory allocated by malloc()?
delete
remove
free
clear
Which of the following creates infinite loop?
for(;;)
while(1)
do {} while(1);
All of the above
How to pass an array to a function?
Size only
Each element
Base address
Last index
Default return type of a function in C if not specified?
int
void
float
undefined
Which data structure uses LIFO?
Queue
Stack
Array
Tree
Which operation is not possible in stack?
push
pop
insert at bottom
top
Which data structure uses FIFO?
Queue
Stack
Tree
Graph
Worst-case time complexity of search in BST?
O(log n)
O(n)
O(n log n)
O(1)
In which traversal is root between left and right subtree?
Preorder
Inorder
Postorder
Level order
Which data structure is used in recursion?
Stack
Queue
Array
List
Degree of a leaf node?
1
2
0
Undefined
Which is a non-linear data structure?
Array
Linked list
Stack
Tree
Used to implement priority queue?
Stack
Queue
Heap
Tree
Time complexity to access array element by index?
O(1)
O(n)
O(log n)
O(n²)
Supports dynamic memory allocation?
Array
Linked list
Stack
Queue
Maximum number of children in binary tree?
1
2
3
n
Traversal for sorting elements in BST?
Preorder
Inorder
Postorder
Level order
Best data structure for undo functionality?
Queue
Stack
Linked List
Array
Best for BFS in graph?
Stack
Queue
Priority Queue
Heap
Not an application of queue?
Printer scheduling
Call center
Undo
CPU scheduling
Null pointers in a binary tree with 4 nodes?
3
4
5
6
Not a valid binary tree type?
Full
Complete
Skewed
Balanced
Best for DFS in graph?
Queue
Stack
Tree
Array
Data structure used in hash tables?
Queue
Stack
Array
Linked list
Tree with at most 2 children?
Binary tree
Ternary tree
AVL tree
B-tree
Not a linear data structure?
Array
Stack
Graph
Queue
Height of a single-node binary tree?
-1
0
1
Undefined
In circular queue, rear just before front means:
Empty
Full
Half
Overflow
Which tree self-balances on insert/delete?
BST
AVL Tree
Binary Tree
Trie
