main()

{

int i=4,j=7;

j = j || i++ && printf("YOU CAN");

printf("%d %d", i, j);

}



main() { int i=4,j=7; j = j || i++ && printf("YOU CAN"); ..

Answer / susie

Answer :

4 1

Explanation:

The boolean expression needs to be evaluated only till the
truth value of the expression is not known. j is not equal
to zero itself means that the expression’s truth value is 1.
Because it is followed by || and true || (anything) => true
where (anything) will not be evaluated. So the remaining
expression is not evaluated and so the value of i remains
the same.

Similarly when && operator is involved in an expression,
when any of the operands become false, the whole
expression’s truth value becomes false and hence the
remaining expression will not be evaluated.

false && (anything) => false where (anything) will
not be evaluated.

Is This Answer Correct ?    5 Yes 0 No

Post New Answer

More C Code Interview Questions

main() { while (strcmp(“some”,”some\0”)) printf(“Strings are not equal\n”); }

1 Answers  


main() { char s[ ]="man"; int i; for(i=0;s[ i ];i++) printf("\n%c%c%c%c",s[ i ],*(s+i),*(i+s),i[s]); }

1 Answers   DCE,


main() { extern int i; i=20; printf("%d",sizeof(i)); }

2 Answers  


main() { char not; not=!2; printf("%d",not); }

1 Answers  


main() { char *p; p="Hello"; printf("%c\n",*&*p); }

1 Answers  






Is the following statement a declaration/definition. Find what does it mean? int (*x)[10];

1 Answers  


typedef struct error{int warning, error, exception;}error; main() { error g1; g1.error =1; printf("%d",g1.error); }

1 Answers  


Is it possible to type a name in command line without ant quotes?

1 Answers   Excel, Infosys,


void main() { int const * p=5; printf("%d",++(*p)); }

3 Answers   Infosys, Made Easy, State Bank Of India SBI,


How we print the table of 2 using for loop in c programing?

14 Answers   HCL, Wipro,


Finding a number which was log of base 2

1 Answers   NetApp,


main( ) { void *vp; char ch = ‘g’, *cp = “goofy”; int j = 20; vp = &ch; printf(“%c”, *(char *)vp); vp = &j; printf(“%d”,*(int *)vp); vp = cp; printf(“%s”,(char *)vp + 3); }

1 Answers  


Categories