5 pts.
 C++ scope resolution operator tell the output and give the reason
#include<iostream.h> #include<conio.h> int a=10; void main() { int a=5; clrscr();

cout<<::a++<<++a<<endl; for(int i=1;i<=3;i++)  { cout<<a++<<::a+2;

  getch();  }

}



Software/Hardware used:
turbo C++
ASKED: March 14, 2010  6:27 PM
UPDATED: July 6, 2010  9:28 PM

Answer Wiki:
the answer to the above problem must be: 106 613713813 solution: cout<<::a++<<++a; it prints 10 and increments the global a value by one and increments local a value and prints it 6 inside loop cout<<a++<<::a+2; first execution 6 13 since a++ prints 6 and increments = 6+1 = 7 , ::a+2 = 11+2 second execution 7 13 a++ prints 7 and increments = 7+1 = 8, ::a+2 = 11+2 since scope a is not incremented third execution 8 13 same type of calculation so the o/p is 106 613713813 tel me if correct
Last Wiki Answer Submitted:  July 6, 2010  10:07 am  by  Nsn   15 pts.
All Answer Wiki Contributors:  Nsn   15 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

You should run the code and analyze the output to get the answer.

 63,535 pts.

 

You are correct Nsn.

Usually, we don’t answer this kind of question here, as it is clearly a homework assignment, and giving the answer to the OP is not going to help him (her).

 63,535 pts.