And how is the input computed. Code below works. int main() { int a, b , c; prin
ID: 3527360 • Letter: A
Question
And how is the input computed. Code below 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
dont copy my answer
consider the inputs 10,0,100
remember (!a)=false iff a is any number other than 0.
1)!a||!b++&&c=(false)||(true)&&(true)=true
2)(a-1 || b/2) && (c*=2))=[(true)||(false)]&&(true)=(true)&&(true)=true
3)((a-- || --b) && (c+=2)=[(true)||(true)]&&true=true
4)(a || !(b && --c))=(true)|| !(false && true)=true
consider the inputs -7,42,0
1)!a||!b++&&c=(true)||(true)&&(false)=true && false=false
2)(a-1 || b/2) && (c*=2))=[(true)||(false)]&&(false)=(true)&&(false)=false
3)((a-- || --b) && (c+=2)=[(true)||(true)]&&true=true
4)(a || !(b && --c))=(true)|| !(true && true)=truee
check it and give me karma points
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.