...
NTA UGC NET JUNE-2023 Paper-2
November 5, 2023
UGC NET CS 2018-DEC Paper-2
November 5, 2023
NTA UGC NET JUNE-2023 Paper-2
November 5, 2023
UGC NET CS 2018-DEC Paper-2
November 5, 2023

NTA UGC NET JUNE-2023 Paper-2

Question 4
What will be the output of the following code?
#include
int main(){
int a,b,c;
a=ox10;
b=o10;
c=a+b;
print(“%d”,c);
return 0;
}
A
20
B
24

C
Garbage
D
Error
Question 4 Explanation: 
a is assigned the hexadecimal value 0x10, which is equivalent to 16 in decimal.
b is assigned the octal value 010, which is equivalent to 8 in decimal.
c is calculated as the sum of a and b, so c = 16 + 8, resulting in c being equal to 24.
The printf statement then prints the value of c as an integer using the %d format specifier.
As a result, the output of this corrected code is 24. The code adds the values of a and b, and it correctly displays the sum, which is 24.

Correct Answer: B
Question 4 Explanation: 
a is assigned the hexadecimal value 0x10, which is equivalent to 16 in decimal.
b is assigned the octal value 010, which is equivalent to 8 in decimal.
c is calculated as the sum of a and b, so c = 16 + 8, resulting in c being equal to 24.
The printf statement then prints the value of c as an integer using the %d format specifier.
As a result, the output of this corrected code is 24. The code adds the values of a and b, and it correctly displays the sum, which is 24.

0 0 votes
Article Rating
Subscribe
Notify of
2 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments

Semicolon is missing is 5th line. So option D is the correct answer

Updated question. Thanks.

2
0
Would love your thoughts, please comment.x
()
x
error: Alert: Content selection is disabled!!