Multiple choice

Which of the following statements is correct for the given program? #include<stdio.h> #include<conio.h> int main() { int a1,a2,c=3,pt; pt=&c; a1=3(c+5); a2=3*(*pt+5); printf(a1=%d,a2=%d,a1,a2); getch(); }

  1. a=24, b=24

  2. a=12, b=24

  3. We cannot perform addition in pointers(*pt+5)

  4. None of these

  5. Error in the program

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

First the value of c=3 is assigned to pt by the statement pt=&c. So in a1=3(c+5), it becomes a1=3*(3+5). So result is a1=24. After that we know that pt is equal to the value of c,  which is 3. So, a2=3(pt+5) becomes a2=3(3+5). The result is again 24. So, both ai and a2 are 24. Therefore, this is the correct option.