What is the output of this C++ program? #include <iostream> using namespace…

ISRO Scientist/Engineer SC 2017Modified — slightly modified from the official paper; see the solution

What is the output of this C++ program?

#include <iostream>
using namespace std;

void square(int *x)
{
   *x = (*x)++ * (*x);
}

void square(int *x, int *y)
{
   *x = (*x) * --(*y);
}

int main()
{
   int number = 30;
   square(&number, &number);
   cout << number;
   return 0;
}

  1. A.

    910

  2. B.

    920

  3. C.

    870

  4. D.

    900

Attempted by 308 students.

Sign up free to check your answer

Sign up free

Explore the full course: Uppsc Computer Operator Grade B

Loading lesson…