retagged by
292 views
1 votes
1 votes

Find the output of the following program :

#include <stdio.h>
main ()
{
int a, b;
int v=3;
int *pv;
a = 2 * (v+5);
pv = &v;
b = 2*(*pv + 5);
printf("\n a=%d b=%d " , a,b);
}
  1. $a = 16$ , $b = 16$
  2. $a = 16$ , $b = 32$
  3. $a = 16$ , $b = 8$
  4. $a = 16$ , $b = 64$
retagged by

1 Answer

Best answer
2 votes
2 votes
a = 2 * (v + 5) = 2 * (3 + 5) = 2 * 8 = 16
b = 2 * (*pv + 5) , now here v and (*pv) represent the same integer value, that is 3 .
so, b = 2 * (3 + 5) = 16, hence a = 16,b = 16
selected by
Answer:

Related questions

0 votes
0 votes
1 answer
1
5 votes
5 votes
3 answers
2
Bikram asked Jan 16, 2017
975 views
What is the output of the following program?main( ){int i=4, z=12;if( i=5 || z 50)printf(“ Gate2017”);elseprintf(“ Gateoverflow”);}Gate2017Gateoverflowsyntax err...