I don\'t know why 1 , -1 and 0 don\'t work. code works: int main() { int a, b ,
ID: 1807627 • Letter: I
Question
I don't know why 1 , -1 and 0 don't work. code works:
int main() { int a, b , c; printf("Enter integers a, b, c: "); scanf ("%i%i%i", &a, &b, &c); if( ((!a || !b++ && c)) == 1) printf("!a || !b++ && c: True "); else printf("!a || !b++ && c: False "); if ( ((a-1 || b/2) && (c*=2)) ==1) printf("(a-1 || b/2) && (c*=2): True "); else printf("(a-1 || b/2) && (c*=2): False "); if ( ((a-- || --b) && (c+=2)) ==1) printf("(a-- || --b) && (c+=2): True "); else printf("(a-- || --b) && (c+=2): False "); if ( (a || !(b && --c)) ==1) printf("a || !(b && --c): True "); else printf("a || !(b && --c): False "); return 0; }
Explanation / Answer
to make all the results false it tells you to work backward so if you started with the last expression you would see that a==0 has to be true for the last expression working backward up to the first equation a==1 then again going back from the bottem expression you can notice b and c cannot equal 0 so then up to the next expression if c is equal to zero the expression would be false so c is equal to -2 then your left to solve for b in the 2nd expression from the top since b at the end connot equal 0 and you need b/2 to equal 0 you need to set b to -1 then the first expression increments b by one so you have to make b -2 so that when it hits the second expression it is -1 so your final answer is a=1 b=-2 c=-2 and the outcome should be all expressions false
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.