What is the output? #include int main() { int i, j, *ptr, *ptr1; i =10; j =10;…

2026

What is the output?

#include

int main()

{

int i, j, *ptr, *ptr1;

i =10;

j =10;

ptr =&i;

ptr1 = &j;

if(ptr ==ptr1)

{

printf(“True”);

}

else

{

printf(“False”);

}

}

Answer: D. FalseThe condition compares the addresses stored in ptr and ptr1, not the values they point to. Since ptr points to variable i and ptr1 points to variable j, and i…

  1. A.

    True

  2. B.

    Compiler error

  3. C.

    No output

  4. D.

    False

Attempted by 298 students.

Show answer & explanation

Correct answer: D

The condition compares the addresses stored in ptr and ptr1, not the values they point to. Since ptr points to variable i and ptr1 points to variable j, and i and j are different variables, their addresses are different. Therefore, the condition ptr == ptr1 evaluates to false, and the else block executes, printing 'False'.

Explore the full course: Gate Guidance By Sanchit Sir

Loading lesson…