wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

OODP FT1 Assessment Questions

Total questions: 30

Worksheet time: 20mins

Name
Class
Date
1.

What is the correct way to declare an integer pointer?

a)

int ptr;

b)

int *ptr;

c)

ptr *int;

d)

int &ptr;

2.

What is the purpose of a function pointer?

a)

To store the return value of a function.

b)

To pass a function as an argument to another function.

c)

To create a new function dynamically.

d)

To call a function from a different file.

3.

Purpose of typedef keyword is---------

a)

To define a constant.

b)

To create an alias for an existing data type.

c)

To declare a function.

d)

To include a header file.

4.

Which statement is valid for the switch construct?

a)

break is required for the default block

b)

Cases must be in ascending order

c)

All cases must end with a semicolon

d)

case values must be constant

5.

Which of the following is used to compare string contents in C?

a)

==

b)

strcmp()

c)

=

d)

equals()

6.

After calling free(ptr), what value does ptr hold?

a)

NULL

b)

Garbage value

c)

The original address (dangling pointer)

d)

Zero

7.

Which of the following is not a valid printf format specifier?

a)

%zu

b)

%lld

c)

%p

d)

%n

8.

What is the missing access specifier for bit-fields in this struct?

a)

char

b)

unsigned int

c)

float

d)

int

9.

What is the missing statement to declare a pointer to a function that takes two integers and returns a float?

a)

float *func(int, int);

b)

float (*func)(int, int);

c)

float *(*func)(int, int);

d)

float (*func())(int, int);

10.

What does strlen("C\0Program") return?

a)

9

b)

1

c)

8

d)

10

11.

How many times will the loop execute?

a)

4

b)

5

c)

6

d)

Infinite times

12.

Find the value of x in this code:

a)

10

b)

15

c)

20

d)

40

13.

This function returns ---------

a)

Fibonacci sequence

b)

Factorial of n

c)

Sum of first n numbers

d)

Power of n

14.

What will be the output?

a)

3.14

b)

3.140000

c)

3.1

d)

Error

15.

Guess the output of the following code:

a)

1

b)

2

c)

3

d)

0

16.

Which of the following is a potential issue with using gets()?

a)

It's slow.

b)

It can cause a buffer overflow.

c)

It can only read strings of a fixed length.

d)

It's deprecated but still safe to use if you're careful.

17.

Output of the below code is:

a)

5 6

b)

6 6

c)

5 7

d)

6 7

18.

What is the difference between const int *p and int * const p?

a)

They are the same.

b)

const int *p makes the pointer constant, int * const p makes the integer constant.

c)

const int *p makes the integer constant, int * const p makes the pointer constant.

d)

const int *p is invalid syntax.

19.

What is a dangling pointer?

a)

A pointer that points to a valid memory location.

b)

A pointer that points to a memory location that has been freed.

c)

A pointer that has not been initialized.

d)

A pointer that points to a constant value.

20.

Identify the correct statement for a switch in C:

a)

Multiple cases can have identical constant expressions

b)

The default statement is optional

c)

switch expressions accept floating-point types

d)

The break is mandatory after every case

21.

Identify the wrong statement:

a)

A for loop can have multiple initialization expressions

b)

The while condition is evaluated before each iteration

c)

A loop variable must be declared globally

d)

Infinite loops are possible in all types of loops

22.

Which of the following causes an infinite loop?

a)

for (i = 0; i < 10; i++)

b)

while (1);

c)

do { } while (i > 10);

d)

for (i = 0; i < 5; i--);

23.

What will be the result of the following code?

a)

Compile-time error

b)

1 2 3 4 5

c)

Infinite Empty loop

d)

1

24.

Output of the following code snippet is:

a)

0 0 0

b)

0 1 0

c)

1 1 1

d)

No output

25.

Find the output of the below code:

a)

x and y are equal

b)

x and y are not equal

c)

Unpredictable

d)

No output

26.

Which of the following statements about the given line of code is true?

int *p = (int*)100;

a)

It is illegal in C

b)

p points to memory location 100, but dereferencing is undefined behavior.

c)

It is always safe to dereference p.

d)

p is an integer variable initialized to 100.

27.

What will be the result of the following expression in C?

int a = 5, b = 10, c = 15;

a = b++ + --c * a;

a)

a = 5, b = 11, c = 14

b)

a = 15, b = 11, c = 14

c)

a = 5, b = 11, c = 14

d)

a = 20, b = 11, c = 14

28.

Given int arr[3][3], which of the following is an incorrect way to access an element?

a)

arr[1][2]

b)

*(arr[1]+2)

c)

*(*(arr+1)+2)

d)

arr[3][3]

29.

Which of the following function declarations is valid in C?

a)

int func(int a, float b = 3.14);

b)

int func(int, float);

c)

int func(void int);

d)

void func(void) int;

30.

To round off x (float), to an int value, the correct way to do is

a)

y = (int)(x + 0.5)

b)

y = int(x + 0.5)

c)

y = (int)x + 0.5

d)

y = (int)((int)x + 0.5)