Determine output:
#include <stdio.h>
void main()
{
char *p = NULL;
char *q = 0;
if(p)
printf(" p ");
else
printf("nullp");
if(q)
printf("q");
else
printf(" nullq");
}
#include <stdio.h>
void main()
{
char *p = NULL;
char *q = 0;
if(p)
printf(" p ");
else
printf("nullp");
if(q)
printf("q");
else
printf(" nullq");
}
A. p q
B. Depends on the compiler
C. x nullq where x can be p or nullp depending on the value of NULL
D. nullp nullq
Answer: Option D
Solution(By Examveda Team)
char *p = NULL is same as char *q = 0.
In both declarations p and q are initialized to null.
Join The Discussion
Comments ( 3 )
Related Questions on Pointer
In C, what is a pointer primarily used for?
A. Decision making
B. Code organization
C. Variable declaration
D. Storing values
In C, how do you declare a pointer variable that can store the address of an integer?
A. int *ptr;
B. ptr int;
C. int ptr;
D. ptr *int;
What is the purpose of the '->' operator in C when used with pointers?
A. Arithmetic operation
B. Indirection operator
C. Member access operator
D. Bitwise operation
They are using 64 bit compiler so the size of pointer in 64 bit compiler is 8 byte...
Is it okay frinds???
Please anyone explain me gow it goes to else loop ,i am getting it
Here if (p) that p gives address n not a value and how it goes to else