Consider the following C++ program' int a (int m) {return ++m;} int b(int&m)…

2018

Consider the following C++ program'

int a (int m)
{return ++m;}
int b(int&m)
{return ++m;}
int c(char &m)
{return ++m;} 

void main 0
{
      int p = 0, q = 0, r = 0; 
      p += a(b(p));
      q += b(a(q));
      r += a(c(r));
      cout<

Assuming the required header files are already included, the above program: 
  1. A.

    results in compilation error

  2. B.

    print 123

  3. C.

    print 111

  4. D.

    print 322

Attempted by 73 students.

Show answer & explanation

Correct answer: A

The provided C++ code contains multiple critical syntax errors that prevent compilation entirely. Specifically, the function declaration void main 0 uses a digit instead of parentheses, and the output statement cout< is syntactically incomplete. Additionally, passing an integer variable to a function expecting a character reference causes a type mismatch error during compilation. Since the code cannot compile successfully, option 0 is the correct answer.

Explore the full course: Isro