Multiple choice

Find out the values of variables a and b after the execution of program or find out the error if any. #include<stdio.h> #include<conio.h> int main() { int a,b=&a,c=&b; a=5; **c=15; *b=*c; printf(a=%d,b=%d,a,*b); getch(); }

  1. a=5, b=15

  2. a=15, b=15

  3. a=5, b=5

  4. a=15, b=5

  5. Error in the program

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

In this program first we assign the value of a to b by the statement (b=&a), which means b contains value of a. Now after that **c contains the value of b (c=&b), which means value of b is in **c. Now we assign **c=15, which means **c=15 and b is also become 15 as (c=&b). Now as (*b=*c), it makes b=15. Now as we know (*b=&a), so value of a also becomes 15. In this way both a and b will be printed as 15.