WorksheetsOODP FT1 Assessment Questions
Total questions: 30
Worksheet time: 20mins
What is the correct way to declare an integer pointer?
int ptr;
int *ptr;
ptr *int;
int &ptr;
What is the purpose of a function pointer?
To store the return value of a function.
To pass a function as an argument to another function.
To create a new function dynamically.
To call a function from a different file.
Purpose of typedef keyword is---------
To define a constant.
To create an alias for an existing data type.
To declare a function.
To include a header file.
Which statement is valid for the switch construct?
break is required for the default block
Cases must be in ascending order
All cases must end with a semicolon
case values must be constant
Which of the following is used to compare string contents in C?
==
strcmp()
=
equals()
After calling free(ptr), what value does ptr hold?
NULL
Garbage value
The original address (dangling pointer)
Zero
Which of the following is not a valid printf format specifier?
%zu
%lld
%p
%n
What is the missing access specifier for bit-fields in this struct?
char
unsigned int
float
int
What is the missing statement to declare a pointer to a function that takes two integers and returns a float?
float *func(int, int);
float (*func)(int, int);
float *(*func)(int, int);
float (*func())(int, int);
What does strlen("C\0Program") return?
9
1
8
10
How many times will the loop execute?
4
5
6
Infinite times
Find the value of x in this code:
10
15
20
40
This function returns ---------
Fibonacci sequence
Factorial of n
Sum of first n numbers
Power of n
What will be the output?
3.14
3.140000
3.1
Error
Guess the output of the following code:
1
2
3
0
Which of the following is a potential issue with using gets()?
It's slow.
It can cause a buffer overflow.
It can only read strings of a fixed length.
It's deprecated but still safe to use if you're careful.
Output of the below code is:
5 6
6 6
5 7
6 7
What is the difference between const int *p and int * const p?
They are the same.
const int *p makes the pointer constant, int * const p makes the integer constant.
const int *p makes the integer constant, int * const p makes the pointer constant.
const int *p is invalid syntax.
What is a dangling pointer?
A pointer that points to a valid memory location.
A pointer that points to a memory location that has been freed.
A pointer that has not been initialized.
A pointer that points to a constant value.
Identify the correct statement for a switch in C:
Multiple cases can have identical constant expressions
The default statement is optional
switch expressions accept floating-point types
The break is mandatory after every case
Identify the wrong statement:
A for loop can have multiple initialization expressions
The while condition is evaluated before each iteration
A loop variable must be declared globally
Infinite loops are possible in all types of loops
Which of the following causes an infinite loop?
for (i = 0; i < 10; i++)
while (1);
do { } while (i > 10);
for (i = 0; i < 5; i--);
What will be the result of the following code?
Compile-time error
1 2 3 4 5
Infinite Empty loop
1
Output of the following code snippet is:
0 0 0
0 1 0
1 1 1
No output
Find the output of the below code:
x and y are equal
x and y are not equal
Unpredictable
No output
Which of the following statements about the given line of code is true?
int *p = (int*)100;
It is illegal in C
p points to memory location 100, but dereferencing is undefined behavior.
It is always safe to dereference p.
p is an integer variable initialized to 100.
What will be the result of the following expression in C?
int a = 5, b = 10, c = 15;
a = b++ + --c * a;
a = 5, b = 11, c = 14
a = 15, b = 11, c = 14
a = 5, b = 11, c = 14
a = 20, b = 11, c = 14
Given int arr[3][3], which of the following is an incorrect way to access an element?
arr[1][2]
*(arr[1]+2)
*(*(arr+1)+2)
arr[3][3]
Which of the following function declarations is valid in C?
int func(int a, float b = 3.14);
int func(int, float);
int func(void int);
void func(void) int;
To round off x (float), to an int value, the correct way to do is
y = (int)(x + 0.5)
y = int(x + 0.5)
y = (int)x + 0.5
y = (int)((int)x + 0.5)
