Consider the following C function definition. int f(int x, int y) { for (int i…

GATE · 2024 · CS · Set 1 · Computer Science & IT

Consider the following C function definition.

                int f(int x, int y) {
                    for (int i = 0; i < y; i++) {
                        x = x + x + y;
                    }
                    return x;
                }

Which of the following statements is/are TRUE about the above function?

  1. A.

    If the inputs are x=20, y=10, then the return value is greater than 220

  2. B.

    If the inputs are x=20, y=20, then the return value is greater than 220

  3. C.

    If the inputs are x=20, y=10, then the return value is less than 210

  4. D.

    If the inputs are x=10, y=20, then the return value is greater than 220

Attempted by 326 students.

Sign up free to check your answer

Sign up free

Explore the full course: Gate Guidance By Sanchit Sir

Loading lesson…