wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Practice Quizz

Total questions: 60

Worksheet time: 30mins

Name
Class
Date
1.

What is a computer program?

a)

A set of instructions for a computer to follow.

b)

A type of hardware component.

c)

A programming language.

d)

A software application.

2.

Which of the following is a valid C statement?

a)

print "Hello, world!";

b)

printf("Hello, world!\n");

c)

echo "Hello, world!";

d)

display "Hello, world!";

3.

What is the purpose of a semicolon (;) in C?

a)

To start a new line.

b)

To end a statement.

c)

To separate variables.

d)

To comment out code.

4.

What does the `%d` format specifier do in `printf()`?

a)

Prints a floating-point number.

b)

Prints a character.

c)

Prints an integer.

d)

Prints a string.

5.

What does the `scanf()` function do?

a)

Prints data to the console.

b)

Reads data from the console.

c)

Declares a variable.

d)

Ends the program.

6.

What does the `if` statement do in C?

a)

Repeats a block of code.

b)

Executes a block of code conditionally.

c)

Declares a variable.

d)

Defines a function.

7.

What does the `for` loop do in C?

a)

Executes a block of code repeatedly.

b)

Executes a block of code conditionally.

c)

Reads data from a file.

d)

Writes data to a file.

8.

What is a comment in C code?

a)

A line of code that is executed.

b)

A line of code that is ignored by the compiler.

c)

A variable declaration.

d)

A function definition.

9.

How do you declare an integer variable named `count` in C?

a)

int count;

b)

integer count;

c)

var count : int;

d)

count = int;

10.

Which of the following is a valid C identifier?

a)

rollNumber 11

b)

roll Number 3

c)

rollNumber_9

d)

65rollNumber

11.

What is the size of a 'float' data type in C (in bytes)?

a)

1

b)

2

c)

4

d)

8

12.

What will happen if you try to use an undeclared variable in your C program?

a)

It will compile without errors.

b)

It will give a compile-time error.

c)

It will give a runtime error.

d)

The program will crash.

13.

Which keyword is used to stop a loop prematurely?

a)

continue

b)

break

c)

both

d)

none

14.

What is the purpose of an assignment operator in C?

a)

Performs arithmetic calculations

b)

Compares two values

c)

Assigns a value to a variable

d)

Performs bitwise operations

15.

What is the result of 10 % 3 in C?

a)

3

b)

3.33

c)

1

d)

0

16.

Which relational operator checks for inequality?

a)

==

b)

!=

c)

>=

d)

<=

17.

What does the logical AND operator (&&) return if both operands are true?

a)

False

b)

True

c)

0

d)

1

18.

What is the bitwise AND operator?

a)

&

b)

|

c)

^

d)

~

19.

What is the result of 5 & 3 (bitwise AND)?

a)

8

b)

1

c)

7

d)

0

20.

What is the result of 5 ^ 3 (bitwise XOR)?

a)

6

b)

2

c)

0

d)

8

21.

What is the bitwise NOT operator?

a)

&

b)

|

c)

^

d)

~

22.

What is the result of ~5 (bitwise NOT, assuming 8-bit representation)?(this question requires calculation, keep in mind the 2's compliment representation while solving)

a)

5

b)

-6

c)

10

d)

-5

23.

What is the precedence(priority) of arithmetic operators compared to assignment operators?

a)

Arithmetic operators have lower precedence.

b)

Assignment operators have lower precedence.

c)

They have equal precedence.

d)

It depends on the context.

24.

What is the result of the expression x += 5; if x initially holds the value 10?

a)

5

b)

10

c)

15

d)

0

25.

What is the result of the expression (10 > 5) || (5 > 10)?

a)

0

b)

1

c)

-1

d)

5

26.

Which operator is used for bitwise XOR?

a)

&

b)

|

c)

^

d)

~

27.

What is the result of (5 > 10) ? 1 : 0;

a)

0

b)

1

c)

5

d)

10

28.

What does the ++ operator do?

a)

Decrements a value by 1

b)

Increments a value by 1

c)

Multiplies by 2

d)

Divides by 2

29.

What is the result of !(1)?

a)

0

b)

1

c)

-1

d)

Error

30.

What action does the following conditional statement perform? if (x = 5)

a)

Checks if x equals 5

b)

Assigns 5 to x and evaluates to true

c)

Assigns 5 to x and evaluates to false

d)

Generates a compiler error

31.

Which statement correctly checks if a number is even in C?

a)

if (number % 2 = 0)

b)

if (number / 2 == 0)

c)

if (number % 2 == 0)

d)

if (number == 2)

32.

What does a nested `if` statement do?

a)

It creates an infinite loop

b)

It allows an `if` statement within another `if` statement

c)

It's a syntax error

d)

It reverses the conditional logic

33.

What does the `else if` statement do?

a)

It allows multiple conditions to be checked sequentially.

b)

It negates the previous `if` statement.

c)

It is a syntax error.

d)

It is equivalent to a nested `if` statement.

34.

What data type is generally used in the `switch` statement's controlling expression?

a)

float

b)

double

c)

char or integer

d)

string

35.

nt's controlling expression?

a)

float

b)

double

c)

char or integer

d)

string

36.

Can a `case` label in a `switch` statement have a range of values?

a)

Yes, using a dash to separate the start and end values.

b)

Yes, using a comma to separate the values.

c)

No, each `case` label must have a single value.

d)

No, only string values are allowed.

37.

What will happen if a `break` statement is omitted from a `case` in a `switch` statement?

a)

The program will crash.

b)

The next case will be executed.

c)

The switch statement will be terminated.

d)

It will compile but cause unpredictable behavior.

38.

What is the purpose of a for loop?

a)

To repeat a block of code indefinitely.

b)

To execute a block of code a specific number of times.

c)

To repeat a block of code until a condition is met.

d)

To execute a block of code only once.

39.

What is the difference between a `for` loop and a `while` loop?

a)

A `for` loop is always faster.

b)

A `while` loop can only iterate once.

c)

A `for` loop is designed for a predetermined number of iterations.

d)

A `while` loop always requires a counter variable.

40.

Which loop guarantees at least one execution?

a)

`for` loop

b)

`while` loop

c)

`do-while` loop

d)

None of the above

41.

A "do-while" loop checks the condition ________ the loop body.

a)

Before

b)

After

c)

During

d)

It doesn't check the condition

42.

What does the "continue" statement do in a loop?

a)

Exits the loop entirely.

b)

Skips the current iteration and proceeds to the next.

c)

Repeats the current iteration.

d)

Stops the program execution.

43.

Can you nest loops inside each other?

a)

Yes

b)

No

c)

Only `for` loops can be nested.

d)

Only `while` loops can be nested.

44.

Can a `for` loop be used to iterate backwards?

a)

Yes

b)

No

45.

What is the purpose of a counter variable in a loop?

a)

To store the loop's condition.

b)

To track the number of iterations.

c)

To control the loop's exit condition.

d)

To store the loop's body.

46.

Which loop is generally preferred when the number of iterations is known beforehand?

a)

`while` loop

b)

`do-while` loop

c)

`for` loop

d)

It depends on the specific task

47.

Is it possible to have a "for" loop with no initialization in syntax statement of for loop?

a)

Yes

b)

No

48.

Is it possible to have a "for" loop with no condition?

a)

Yes

b)

No

49.

How is an array declared in C?

a)

int array = [10];

b)

int array[10];

c)

int array(10);

d)

int array = {10};

50.

What is the size of an array declared below? int numbers[5];

a)

4 bytes

b)

5 bytes

c)

20 bytes (assuming int is 4 bytes)

d)

5 * sizeof(int) bytes

51.

What will happen if you try to access array[-1]` where `array` is an integer array?

a)

The program compiles but crashes at runtime.

b)

The program compiles and runs without any errors.

c)

The compiler reports an error.

d)

The last element of the array is accessed.

52.

Are array elements automatically initialized to zero in C?

a)

Yes, always

b)

No, unless initialized

53.

What's the output of this code snippet? int arr[5] = {1, 2, 3, 4}; printf("%d", arr[3]);

a)

3

b)

4

c)

Garbage value

d)

Compilation error

54.

What is an advantage of using arrays?

a)

Easy access to elements using their index

b)

Dynamic resizing

c)

Heterogeneous data storage

d)

None of the above

55.

Can an array be initialized at the time of its declaration?

a)

Yes, using curly braces {}

b)

No, initialization must be done separately.

c)

Only if the array is globally declared.

d)

Only if the array's size is known at compile time.

56.

Which of the following is NOT a valid way to declare an array of 5 integers?

a)

int arr[5];

b)

int arr[5] = {0};

c)

int arr[5] = {1, 2, 3, 4, 5, 6};

d)

int arr[] = {1, 2, 3, 4, 5};

57.

Which loop is can be used in the implementation of a linear search in C?

a)

`for` loop

b)

`while` loop

c)

`do-while` loop

d)

All of the above

58.

What is the advantage of binary search over linear search?

a)

Simpler implementation

b)

Faster search time for large datasets

c)

Works with unsorted data

d)

Uses less memory

59.

Binary search is more efficient than linear search when:

a)

the data set is small

b)

the data set is large and sorted

c)

the data set is unsorted

d)

the data set contains duplicates

60.

In Bubble Sort, what is the purpose of the inner loop?

a)

To divide the array into smaller subarrays

b)

To compare and swap adjacent elements

c)

To find the maximum element

d)

To merge sorted subarrays