NEW
Font size
WorksheetsOODP_Batch 1_Quiz
Total questions: 30
Worksheet time: 15mins
Guess the output of the following code:
2.500000
2.000000
2
Compilation Error
How many times will the loop execute?
4
5
6
Infinite times
What is the correct way to declare an integer pointer is
int ptr;
int *ptr;
ptr *int;
int &ptr;
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
Output of the following code is:
True
False
Error
Undefined behaviour
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.
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.
Output of the below code is:
5 6
6 6
5 7
6 7
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.
What is the output of the following code:
Hello
Jello
H
Error
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 the output of the following code:
5
10
15
Error
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--);
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
Pointer arithmetic is not possible on ___.
Integer pointers
Float pointers
Character pointers
Void pointers
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)
Fill in the missing statement to copy a string in C:
strcat
strncpy
strcpy
strcmp
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);
----------------- keyword is used to declare a function that cannot be modified in other source files.
static
volatile
const
extern
Which of the following is not a valid printf format specifier?
%zu
%lld
%p
%n
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;
What does the following code print?
10
20
Compile-time Error
Run-time Error
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]
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
