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.
Consider the following statements in reference to Punjab Preservation of Subsoil Water Act, 2009.
1.   As per the Act, no farmer shall sow...
For the current fiscal year 2022 -23, the government has increased the agricultural credit target from earlier Rs 16.50 lakh crore to how much _______?
Which of the following is NOT typically part of configuring browser synchronization across devices?
The ages of Mr. Kumar and his son are in the ratio 5:3. Fifteen years back this ratio was 2 :1. What was the age (in years) of Mr. Kumar when his son wa...
As per the RBI, the definition of hedging includes mitigating which type of risk?
In which Indian state Gangaur Festival is predominantly celebrated:
Who among the following served the shortest tenure as the Prime Minister of India?
Members of which of the following phyla are commonly known as sea walnuts?
Which official received credentials from five foreign ambassadors at the start of their term in July 2023?
Ravana Phadi cave and Durga Temple at Aihole portray the architectural style of which dynasty?