Active Topics Memberlist Calendar Search Help | |
Register Login |
One Stop GATE Forum : GATE AT A GLANCE : Test Series |
Topic: Test01 Q12 CS output of given pgm!!! | |
Author | Message |
manju
Senior Member Joined: 20Feb2007 Online Status: Offline Posts: 221 |
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 Logged | |
balu
Senior Member Joined: 20Feb2007 Online Status: Offline Posts: 236 |
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 Logged | |
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 |
|
© Vyom Technosoft Pvt. Ltd. All Rights Reserved.