Topic Wise Solved Problems Question – Computer Sir Ki Class

Login


Lost your password?

Don't have an account ?
Register (It's FREE) ×
  


Shop
siteicon
CPP: Topicwise Exam Question: functions-reference-passing-returning siteicon
01D 2

Write the output of the following C++ program code:
Note: Assume all required header files are already being included in the program .

void Position (int &C1, int C2=3)
{
  C1+=2;
  C2+=Y;
}
void main()
{
  int P1=20, P2=4;
  Position(P1);
  cout<<P1<<”,”<<P2<<endl;
  Position(P2,P1);
  cout<<P1<<”,”<<P2<<endl;
}
CBSE12D-2015

Output writing – Function – pass by reference 3

Find and write the output of the following C++ program code: Note : Assume all required header files are already included in the program.

void Revert(int &Num, int Last=2)
{
  Last=(Last%2==0)?Last+1:Last-1;
  for(int C=1; C<=Last; C++)
  Num+=C;
}

void main()
{
  int A=20,B=4;
  Revert(A,B);
  cout<<A<<"&"<<B<<endl;
  B--;
  Revert(A,B);
  cout<<A<<"#"<<B<<endl;
  Revert(B);
  cout<<A<<"#"<<B<<endl;
}
CBSE12A-2018

01D-2015 2

Write the output of the following C++ program code:
Note: Assume all required header files are already being included in the program.

void Location(int &X,int Y=4)
{
  Y+=2;
  X+=Y;
}
void main()
{
  int PX=l0,PY=2;
  Location(PY) ;
  cout<<PX<<" , "<<PY<<endl ;
  Location(PX,PY);
  cout<<PX<<" , "<<PY<<endl ;
}
CBSE12A-2015