1,289 views
1 votes
1 votes
#include "stdio.h"

 int * gPtr;

int main()
{
int * lPtr = NULL;

if(gPtr == lPtr)
{
printf("Equal!");
}
else
{
printf("Not Equal");
}

return 0;
}

what will be the outpout :

A.> it will always print equal

B> it will always print Not equal

C>Since gPtr isn’t initialized in the program, it’ll print sometimes Equal and at other times Not Equal.

2 Answers

0 votes
0 votes
Ans is A.

Global variables (pointers or data members) are always assigned a default value at compilation. Hence the default value for gPtr is NULL.
0 votes
0 votes
Global variables are by default NULL and the ASCII value of NULL is 0.So 0=0 is true hence output would be EQUAL!

Related questions

1 votes
1 votes
2 answers
1
Anil Khatri asked Sep 9, 2016
971 views
What will be the output of the program?#include<stdio.h int main() { const c = -11; const int d = 34; printf("%d, %d\n", c, d); return 0; } A. Error B. -1...
0 votes
0 votes
1 answer
2
0 votes
0 votes
2 answers
3
Anil Khatri asked Sep 8, 2016
1,862 views
What will be the output of the program?#include<stdio.h>int main(){ char c=48; int i, mask=01; for(i=1; i<=5; i++) { printf("%c", c|mask); mask ...
3 votes
3 votes
2 answers
4
Anil Khatri asked Sep 8, 2016
3,236 views
What will be the output of the program ?#include<stdio.h int main() { int i=4, j=8; printf("%d, %d, %d\n", i|j&j|i, i|j&j|i, i^j); return 0; } A. 12, 12, 12 B. ...