Question

Write a C program, called logic_abc.c, that prompts the user to enter three integers a, b,...

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)

Homework Answers

Answer #1

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:

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
In a file called ThreeOperations.java, write a program that: Asks the user to enter two real...
In a file called ThreeOperations.java, write a program that: Asks the user to enter two real numbers (doubles, not integers) called N1 and N2. It is OK if your program crashes when the user does not enter valid double numbers. Computes and displays the following operations between the two: multiplication, division, exponentiation. For the results of these two operations, only two decimal digits should be displayed.
In C++ write a program that prompts the user to enter two positive integers less than...
In C++ write a program that prompts the user to enter two positive integers less than 1,000,000,000 and the program outputs the sum of all the prime numbers between the two integers. Two prime numbers are called twin primes, if the difference between the two primes is 2 or -2. Have a program output all the twin primes and the number of twin primes between the two integers. NEEDED OUTPUTS FOR PROGRAM: Enter two positive integers <1,000,000,000: 1 100 -1...
Write a C program that asks the user to enter two integers x and n. Then...
Write a C program that asks the user to enter two integers x and n. Then the program computes xn (=x * x * x …… (n times)) using for loop. using printf scanf
Write a Python program that prompts a user for two integers and stores the two integers...
Write a Python program that prompts a user for two integers and stores the two integers the user types into the shell. Print the product, float division, integer division, remainder, sum, and difference of the two integers to the console. The entire equation must be printed (see below for formatting). Only display 2 digits after the decimal place for results that are floats. Include a module docstring that summarizes the program.. Sample Run 1: Enter an integer: 5 Enter another...
Q :     Write a C++ program that asks the user to enter three integers and...
Q :     Write a C++ program that asks the user to enter three integers and then displays the largest one. Example : if the user enter ( 7, 2 ,5) the largest number will be 7 Or if user enter ( 2 , 5 , 7 ) the largest number will be 7 Or if user enter ( 7, 5 ,2) the largest number will be 7 In general it does not matter the order of the entered numbers...
Write a program that asks the user for three integers (firstInt, secondInt, thirdInt). Perform the following...
Write a program that asks the user for three integers (firstInt, secondInt, thirdInt). Perform the following operations and output the results: firstResult = Add firstInt and secondInt then divide the result by thirdInt secondResult = Multiply secondInt by thirdInt and divide result by the sum of secondInt and firstInt thirdResult = Multiply firstInt by thirdInt and find the remainder of dividing the result by secondInt Your prompts to the user to enter the integers must be: Enter firstInt: Enter secondInt:...
Write a C++ fragment that prompts the user to enter integers one at a time, keeping...
Write a C++ fragment that prompts the user to enter integers one at a time, keeping track of the total number of odd numbers entered. If a negative number is entered, stop asking for numbers and print the result. Assume all needed headers are included.
Write a program that prompts the user to enter a string and displays the number of...
Write a program that prompts the user to enter a string and displays the number of characters it contains, fourth character, and last character. Note: The string may contain blanks. For example: “C++ programming is fun”. You should write a complete program.
Write a complete program that prompts the user to enter the number of students and each...
Write a complete program that prompts the user to enter the number of students and each student’s score, then finally displays the highest score.(in C++)
Write a program that asks the user to enter three different integers; if the entered three...
Write a program that asks the user to enter three different integers; if the entered three integers contain two or more that are the same, print message "wrong input"; otherwise the program prints the largest number in the three. Implement your code using decision structures (namely, if and/or if-else). In the execution of your code, try the following test cases. Test case 1: input (3, 4, 5) Test case 2: input (3, 3, 5) Test case 3: input (3, 5,...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT