Question
What will be the output of the following C code?
#include < stdio.h > void main ( ) { Â Â int x = 10, y = 20, *p1 = &x, *p2 = &y; Â Â *p2 = *p1 + *p2; Â Â printf ("%d %d\n", x, y); }Solution
The code demonstrates pointer manipulation in C. Here’s a breakdown: • int x = 10, y = 20; declares two integers, x and y. • *p1 = &x, *p2 = &y; initializes p1 to point to x and p2 to point to y. • *p2 = *p1 + *p2; fetches the values of x and y through p1 and p2 respectively, adds them, and assigns the result back to y via *p2. After this operation, y becomes 30, while x remains 10. Output: 10 30. Why Other Options Are Incorrect: 1. 10 20: This would occur if no pointer manipulation happened, but the code modifies y. 2. 30 10: Only y is updated, not x. 3. Compiler error: The code is syntactically correct and compiles successfully. 4. Undefined behavior: The pointers are used properly with valid memory addresses, avoiding undefined behavior.
Statements: G < O = H ≥ L > F < U≤ T ≥ Z
Conclusion:
I. L ≤ O
II. T > L
In which of the following expressions will the expression ‘M ≥ N ' and ‘Q < O’ be definitely true?
Statement: C < X ≤ B > E < L < I
Conclusion: I. X > LÂ Â Â Â Â Â Â Â Â Â II. B > C
Statements: B < C ≤ D < A ≥ Y
Conclusion: I. A > B II. Y < C
...Statements: M > N > P ; P = Q ; N < R
Conclusions:
I. Q < N
II. P < M
III. M > R
Statements: G ≤ H < I = J > K, L < B ≥ V > I ≥ D
Conclusion:
I. G = D
II. K ≤ D
III. B > H
Statements: L ≥ R, U ≤ N, N < M > I
Conclusion:
I. R > I
II. M ≥ U
Statements: P ≥ Q > R, S ≤ R, T = W ≥ R
Conclusions:
I. T ≥ S
II. Q < W
If the expression E < B > D = G ≥ H is definitely true, which of the following would be definitely true?
In the following question the relationship between different elements is given in the statements followed by two conclusions I and II. Read the stateme...