
7_sem
Authored by AKSV AKSV
Information Technology (IT)
University
Used 1+ times

AI Actions
Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...
Content View
Student View
30 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What will be the output? int x = 10; printf("%d %d", x, x++);
10 11
11 10
Undefined behavior
10 10
Answer explanation
The expression 'x++' modifies 'x' after its current value is used. Since 'x' is evaluated twice without a sequence point, it leads to undefined behavior. Thus, the output is not predictable, making 'Undefined behavior' the correct choice.
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which keyword is used to avoid multiple inclusions of header files?
static
extern
#pragma once
const
Answer explanation
The keyword #pragma once is used in C and C++ to prevent multiple inclusions of the same header file, ensuring that the file is included only once per compilation unit. This helps avoid redefinition errors.
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Output? printf("%d", sizeof("Hello"));
5
6
4
Compiler error
Answer explanation
The expression sizeof("Hello") calculates the size of the string literal, which includes the null terminator. "Hello" has 5 characters plus 1 for the null terminator, totaling 6. Thus, the correct answer is 6.
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which sorting has best case O(n)?
Bubble sort
Insertion sort
Merge sort
Quick sort
Answer explanation
Insertion sort has a best case time complexity of O(n) when the input array is already sorted. In this scenario, it only requires a single pass through the array, making it more efficient than the other sorting algorithms listed.
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which operator has the highest precedence?
* (dereference)
++
()
[]
Answer explanation
The operator with the highest precedence is '()' (parentheses), which is used for grouping expressions and function calls. It takes precedence over dereference, increment, and array subscripting operators.
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which storage class allows local persistence of variables?
auto
static
register
extern
Answer explanation
The 'static' storage class allows variables to maintain their value between function calls, providing local persistence. In contrast, 'auto' and 'register' do not retain values after the function exits, and 'extern' is used for global variables.
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which of the following is not a valid string function in standard C?
strcpy()
strcat()
strrev()
strlen()
Answer explanation
The function strrev() is not part of the standard C library. The other functions, strcpy(), strcat(), and strlen(), are valid string functions used for copying, concatenating, and measuring string length, respectively.
Access all questions and much more by creating a free account
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
Already have an account?