C program called logic abcc that prompts the user to enter t

C program, called logic abc.c, that prompts the user to enter three integers a, b, c, and then computes the results of the following logical operations, in sequence:

!a || !b++ && c

(a-1 || b/2) && (c*=2)

(a-- || --b) && (c+=2)

a || !(b && --c)

Here are three sample runs of this a program, assuming that the executable file is called logic abc

Enter integers a, b, c: 1 1 1

!a || !b++ && c: False

(a-1 || b/2) && (c*=2): True

(a-- || --b) && (c+=2): True

a || !(b && --c): False

--------------------------------------

Enter integers a, b, c: -7 42 0

!a || !b++ && c: False

(a-1 || b/2) && (c*=2): False

(a-- || --b) && (c+=2): True

a || !(b && --c): True

-----------------------------------------

Enter integers a, b, c: 10 0 1000

!a || !b++ && c: True

(a-1 || b/2) && (c*=2): True

(a-- || --b) && (c+=2): True

a || !(b && --c): True

----------------------------------

Question

Are there values of a, b, and c that would make all the results False? Submit your answer to this question as a comment in your program. Please explain clearly how you have arrived at this answer. Hint: It may be useful to start with the last expression and work backwards.

Solution

#include<stdio.h>

int main()
{
//declare variable a, b , c
int a, b, c;

//ask user to input
printf(\"Enter three integers a, b, c: \");
scanf(\"%d%d%d\", &a, &b, &c);

if (!a || !b++ && c)
printf(\"!a|| !b++ && c: True\ \");
else
printf(\"!a||!b++ && c: False\ \");
  
if ((a - 1 || b / 2) && (c *= 2))
printf(\"(a - 1|| b / 2) && (c *= 2): True\ \");
else
printf(\"(a - 1||b / 2) && (c *= 2): False\ \");

if ((a-- || --b) && (c += 2))
printf(\"(a-- || --b) && (c += 2): True\ \");
else
printf(\"(a-- || --b) && (c += 2): False\ \");

if (a || !(b && --c))
printf(\"a || !(b && --c): True\ \");
else
printf(\"a || !(b && --c): False\ \");

}

//output1

Enter three integers a, b, c: 1 1 1
!a || !b++ && c: False
(a - 1 || b / 2) && (c *= 2): True
(a-- || --b) && (c += 2): True
a || !(b && --c): False

//output2:

Enter three integers a, b, c: -7 42 0
!a || !b++ && c: False
(a - 1 || b / 2) && (c *= 2): False
(a-- || --b) && (c += 2): True
a || !(b && --c): True

----------------------------------------------------

//output3:

Enter three integers a, b, c: 10 0 1000
!a || !b++ && c: True
(a - 1 || b / 2) && (c *= 2): True
(a-- || --b) && (c += 2): True
a || !(b && --c): True

C program, called logic abc.c, that prompts the user to enter three integers a, b, c, and then computes the results of the following logical operations, in sequ
C program, called logic abc.c, that prompts the user to enter three integers a, b, c, and then computes the results of the following logical operations, in sequ

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site