Write a 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)
Program:
#include<stdio.h>
int main(){
int a,b,c; // variable declaration
printf("Enter three integers: ");
scanf("%d%d%d",&a,&b,&b); // Accept three integers
int p = (!a || (!b++ && c)); // perform logiacal operation
int q = ((a-1 || b/2) && (c*=2)); // perform logiacal operation
int r = (a-- || --b) && (c+=2); // perform logiacal operation
int s = (a || !(b && --c)); // perform logiacal operation
/* It print 1 logical operation value is 1 otherwise 0*/
if(p==1)
printf("True\n");
else
printf("False\n");
if(q==1)
printf("True\n");
else
printf("False\n");
if(r==1)
printf("True\n");
else
printf("False\n");
if(s==1)
printf("True\n");
else
printf("False\n");
return 0;
}
Output:
Get Answers For Free
Most questions answered within 1 hours.