2,532 views
0 votes
0 votes

Please tell why answer is (d)?

2 Answers

0 votes
0 votes
option D is wrong ,

correct option is (A)..

code will run properly

code:

#include<stdio.h>
#include<conio.h>
int x=0;
int f();
int g();
void main(){
int i = (f() + g()) || g();
int j = g() || (f() + g());
printf("%d,%d",i ,j);
getch();
}
int f(){
if(x==0)
return x+1;
else
return x-1;
}
int g(){
return x++;
}

There is not single error in code, value of i and j after execution will be 1 ,1. U can check it..
0 votes
0 votes
i and j is undefined because it is compiler dependent

order of evaluation for values inside function is not mentioned

therefore we cannot be sure hoe the value bbetween the brackets are evaluated and therefore cant be sure of the answer

try it on different compilers, it will give different results

correct me if i am wrong

Related questions

2 votes
2 votes
1 answer
2
1 votes
1 votes
1 answer
4
nish kim asked Sep 2, 2017
5,385 views
{double b =5 & 3 && 4 || 6 | 6 ;printf("%lf",b);}a.2.000000b.1.0c.1.000000d.compilation error