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.
Recently Infibeam avenue received a _______ licence from RBI for Bharat Bill Payment.
What technology does the Quantum Gravity Gradiometer Pathfinder use to detect gravity anomalies?
What is the prize pool for the Bihar Khel Pratibha Khoj Pratiyogita?
Which article of the Indian Constitution deals with the annual financial statement?
What is the purpose of the Reserve Bank of India (RBI) introducing a Fully Accessible Route (FAR) for investments in sovereign green bonds?
What initiative was launched to spread awareness about cybercrime and build capacities of CISOs?Â
Which author has been awarded the prestigious 'German Peace Prize'?
Which of the following statement/statements is/are correct regarding the Interim Union Budget for 2024-2025 presented by Finance Minister Nirmala Sithar...
The Bumchu Festival is celebrated at which monastery?
Actor and BJP leader Hema Malini, and ______ will be facilitated with the Indian Film Personality of the Year award at the International Film Festival ...