1,541 views
0 votes
0 votes
#include<stdio.h>
int main()
{
    int i=10;
    static int x=i;
    if(x==i)
    printf("Equal");
    else if(x>i)
    printf("Greater");
    else
    printf("Lesser");
    return 0;
}

(a) Equal (b) Greater (c) Lesser (d) Compile Error

1 Answer

Best answer
4 votes
4 votes

Answer will be D) Compile Error

Error in this line

static int x = i;

You can not initialize a static variable with a variable. It should be constant or symbolic constant. 

selected by

Related questions

0 votes
0 votes
1 answer
1
Desert_Warrior asked May 16, 2016
2,318 views
#include<stdio.h int main() { int a = 5; int b = ++a * a++; printf("%d ",b); return 0; }(a) 25 (b) 30 (c) 36 (d) Undefined Behavior
0 votes
0 votes
2 answers
2
Desert_Warrior asked May 16, 2016
8,798 views
#include<stdio.h int main() { int a = 5; switch(a) { default: a = 4; case 6: a ; case 5: a = a+1; case 1: a = a-1; } printf("%d \n",a); return 0; }(a) 5 (b) 4 (c) 3 (d) N...
0 votes
0 votes
1 answer
4
Desert_Warrior asked May 16, 2016
5,135 views
#include<stdio.h int main() { char c=125; c=c+10; printf("%d",c); return 0; }(a) 135 (b) +INF (c) -121 (c) -8