What will be output if execute the following c code?
#include<stdio.h>
int main()
{
int i=10;
static int x=i;
if(x==i)
printf("Equal");
else if(x>i)
printf("Greater than");
else
printf("Less than");
return 0;
}
OUTPUT:
a) Equal
b) Greater than
c) Less than
d) Compiler error
e) None of above
Answer: (d)
Explanation: Static variables are load time entity while auto variables are run time entity. We cannot initialize any load time variable by the run time variable.In this example i is run time variable while x is load time variable.
No comments:
Post a Comment