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() { if (!(1&&0)) { printf("OK I am done."); } else { printf("OK I am gone."); } } a. OK I am done b. OK I am gone c. compile error d. none of the above

3 Answers   HCL,


main() { int i=400,j=300; printf("%d..%d"); }

3 Answers  


Program to Delete an element from a doubly linked list.

4 Answers   College School Exams Tests, Infosys,


program to find magic aquare using array

4 Answers   HCL,


main() { char c; int i = 456; clrscr(); c = i; printf("%d", c); } a. 456 b. -456 c. random number d. none of the above

3 Answers   BrickRed, HCL,






What is the output of the program given below main() { signed char i=0; for(;i>=0;i++) ; printf("%d\n",i); }

1 Answers  


main() { char *cptr,c; void *vptr,v; c=10; v=0; cptr=&c; vptr=&v; printf("%c%v",c,v); }

1 Answers  


void main() { int i=10, j=2; int *ip= &i, *jp = &j; int k = *ip/*jp; printf(“%d”,k); }

1 Answers  


how to test pierrot divisor

0 Answers  


To Write a C program to remove the repeated characters in the entered expression or in entered characters(i.e) removing duplicates. String contains only lowercase characters ['a'-'z']

0 Answers  


C program to print magic square of order n where n > 3 and n is odd

2 Answers   Accenture,


void main() { static int i=i++, j=j++, k=k++; printf(“i = %d j = %d k = %d”, i, j, k); }

3 Answers  


Categories