2,386 views
1 1 vote
#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 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 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!
Position:
Show:

Related questions

5 5 votes
2 2 answers
738
738 views
amar100 asked Nov 3, 2024
738 views
#include <stdio.h int main() {short a[3] = {3, 6, 9, 12, 15, 18};printf("%d\n", *(a + 1) );return 0; }The output is 15. How is the output is 15? , In my thinking it must...
2 2 votes
4 4 answers
1.8k
1.8k views
Anil Khatri asked Sep 9, 2016
1,770 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 0 votes
1 1 answer
936
936 views
Anil Khatri asked Sep 8, 2016
936 views
What will be the output of the program assuming that the array begins at the location 1002 and size of an integer is 4 bytes?#include<stdio.h>int main(){ int a[3][4] =...
0 0 votes
2 answers 2 answers
2.4k
2.4k views
Anil Khatri asked Sep 8, 2016
2,375 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 ...