Active TopicsActive Topics  Display List of Forum MembersMemberlist  CalendarCalendar  Search The ForumSearch  HelpHelp
  RegisterRegister  LoginLogin
 One Stop GATE ForumGATE AT A GLANCETest Series
Message Icon Topic: Test01 Q12 CS output of given pgm!!! Post Reply Post New Topic
Author Message
manju
Senior Member
Senior Member


Joined: 20Feb2007
Online Status: Offline
Posts: 221
Quote manju Replybullet Topic: Test01 Q12 CS output of given pgm!!!
    Posted: 23Feb2007 at 2:48pm
 int i= 10;
void main()
{ int i=5;
printf(i);
{int i=2;
printf(i);
{i+=3;
printf(i);
}
i++;
printf(i);
}i+=3;
printf(i);
f();
}

f()
{
printf(i);
{ int i= 15;
printf(i);
}
}

Ans given is D: 5,2,5,6,8,10,15

how come 6 will be there ?? am i missing some scope rules??



Post Resume: Click here to Upload your Resume & Apply for Jobs

IP IP Logged
balu
Senior Member
Senior Member


Joined: 20Feb2007
Online Status: Offline
Posts: 236
Quote balu Replybullet Posted: 23Feb2007 at 2:49pm
 Hi,

You are missing out scope..
int i=2;
First 3 gets added to it
Then it is printed and then incremented
So answer is 6

JAI HIND
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum

GET LATEST FRESHERS JOBS IN YOUR MAIL





This page was generated in 0.094 seconds.
Vyom is an ISO 9001:2000 Certified Organization

© Vyom Technosoft Pvt. Ltd. All Rights Reserved.

Job Interview Questions | Girls Magazine | DLL, OCX File Errors | Freshers Jobs | Placement Papers | More Papers