in GATE retagged by
297 views
1 vote
1 vote

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$
in GATE retagged by
by
297 views

1 Answer

2 votes
2 votes
Best answer
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

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true

64.3k questions

77.9k answers

244k comments

80.0k users