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. False — 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…
- A.
True
- B.
Compiler error
- C.
No output
- 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'.
Loading lesson…