wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

C Language and Data Structures Quiz

Total questions: 30

Worksheet time: 15mins

Name
Class
Date
1.

Which of the following is the correct syntax to declare a pointer in C?

a)

int *ptr;

b)

int ptr*;

c)

int &ptr;

d)

pointer int ptr;

2.

What will be the output of this code? #include int main() { int a = 5; printf("%d", a++ + ++a); return 0; }

a)

11

b)

12

c)

10

d)

Undefined behavior

3.

Which header file is needed to use the printf function?

a)

stdlib.h

b)

stdio.h

c)

string.h

d)

conio.h

4.

What is the size of int on a typical 32-bit system?

a)

2 bytes

b)

4 bytes

c)

8 bytes

d)

Compiler dependent

5.

What will be the output of the following code? #include int main() { int x = 10; if (x = 5) printf("True"); else printf("False"); return 0; }

a)

True

b)

False

c)

Compilation error

d)

Runtime error

6.

Which operator is used to access the value at the address stored in a pointer?

a)

&

b)

*

c)

->

d)

.

7.

What is the output of the following code? #include int main() { char str[] = "Hello"; printf("%c", *str); return 0; }

a)

H

b)

e

c)

o

d)

l

8.

Which of the following is a loop in C?

a)

repeat-until

b)

loop...end

c)

for

d)

foreach

9.

Which data type is used to create a variable that should store text (string)?

a)

char[]

b)

string

c)

str

d)

text

10.

What will be the result of sizeof(char) in C?

a)

1

b)

2

c)

4

d)

Depends on system

11.

Which data structure uses LIFO (Last In First Out) order?

a)

Queue

b)

Stack

c)

Array

d)

Linked List

12.

What is the time complexity of searching in a balanced binary search tree (BST)?

a)

O(1)

b)

O(n)

c)

O(log n)

d)

O(n log n)

13.

Which of the following data structures is used in Breadth-First Search (BFS) of a graph?

a)

Stack

b)

Queue

c)

Priority Queue

d)

Tree

14.

Which data structure is most suitable for implementing recursion?

a)

Queue

b)

Heap

c)

Stack

d)

Tree

15.

Which of the following is not a linear data structure?

a)

Array

b)

Stack

c)

Linked List

d)

Tree

16.

In a circular queue, how do you check if the queue is full?

a)

front == rear

b)

(rear + 1) % size == front

c)

rear == size - 1

d)

rear == -1

17.

Which data structure allows insertion and deletion only from one end?

a)

Deque

b)

Queue

c)

Stack

d)

Array

18.

What is the worst-case time complexity of QuickSort?

a)

O(n log n)

b)

O(n²)

c)

O(log n)

d)

O(n)

19.

Which traversal method is used to get the contents of a BST in sorted order?

a)

Pre-order

b)

In-order

c)

Post-order

d)

Level-order

20.

Which of the following is the best data structure for implementing a priority queue?

a)

Stack

b)

Queue

c)

Heap

d)

Linked List

21.

What does HTML stand for?

a)

Hyper Trainer Marking Language

b)

Hyper Text Markup Language

c)

Hyper Text Marketing Language

d)

Hyper Text Mark Language

22.

Which of the following is not an operating system?

a)

Windows

b)

Linux

c)

Oracle

d)

MacOS

23.

What is the main function of an operating system?

a)

Compiling programs

b)

Controlling hardware and software resources

c)

Creating web pages

d)

Managing databases

24.

In MS Word, which shortcut is used to bold the selected text?

a)

Ctrl + I

b)

Ctrl + B

c)

Ctrl + U

d)

Ctrl + P

25.

What does the command git init do in Git?

a)

Deletes the repository

b)

Creates a new repository

c)

Updates a file

d)

Clones a repository

26.

Which language is used for styling web pages?

a)

HTML

b)

CSS

c)

Java

d)

Python

27.

In MS Excel, what does the function =SUM(A1:A5) do?

a)

Multiplies A1 to A5

b)

Adds cells A1 to A5

c)

Subtracts A5 from A1

d)

Finds the average

28.

What is the default port number for HTTP?

a)

21

b)

25

c)

80

d)

443

29.

Which of the following is a version control system?

a)

Git

b)

Chrome

c)

Excel

d)

Docker

30.

What does CPU stand for?

a)

Central Process Unit

b)

Central Processing Unit

c)

Control Processing Unit

d)

Central Peripheral Unit