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: preprocessor-directives-and-macros siteicon
01D 2

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

#define Big(A,B) (A>B)?A+1:B+2
void main()
{
  char W[] = "Exam";
  int L=strlen(W);
  for(int i =0; i<L-1; i++)
     W[i] = Big(W[i],W[i+1]);
  cout<<W<<endl;
}
CBSE12D-2017

01C-2016 2

Rewrite the following C++ code after removing any/all syntactical errors with
each correction underlined.
Note: Assume all required header files are already being included in the program.

#define Equation(p,q) = p+2*q
void main()
{
  float A=3.2;B=4.1;
  C=Equation(A,B);
  cout<<'Output='<<C<<endl;
}
CBSE12D-2016

01C 2

Observe the following C++ code very carefully and rewrite it after removing any/all syntactical errors with each correction underlined.
Note: Assume all required header files are already being included in the program.

#Define float Max=70.0;
void main()
{
  int Speed
  char Stop='N';
  cin>>Speed;
  if Speed>Max
    Stop='Y';
  cout<<Stop<<end;
}
CBSE12D-2015

Macro definition for array filling 2

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

#define Diff(N1,N2) ((N1>N2)?N1-N2:N2-N1)
void main()
{
  int A,B,NUM[] = {10,23,14,54,32};
  for(int CNT =4; CNT>0; CNT--)
  {
    A=NUM[CNT];
    B=NUM[CNT-1];
    cout<<Diff(A,B)<<'#';
  }
}

 

CBSE12A-2017

Finding and removing Syntax Errors 2

Rewrite the following C++ code after removing any/all syntactical errors with each correction underlined.

Note: Assume all required header files are already being included in the program.

#define Formula(a,b) = 2*a+b
void main()
{
  float X=3.2;Y=4.1;
  Z=Formula(X,Y);
  cout<<'Result='<<Z<<endl;
}
CBSE12A-2016

01C-2015 2

after removing any/all syntactical errors with each correction underlined.
Note: Assume all required header files are already being included in the program.

#Define float MaxSpeed=60.5;
void main()
{
  int MySpeed
  char Alert='N' ;
  cin»MySpeed;
  if MySpeed>MaxSpeed
  Alert='Y' ;
  cout<<Alert<<endline;
}
CBSE12A-2015