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
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 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 prompts the user to enter time in 12-hour notation. The program then...
Write a program that prompts the user to enter time in 12-hour notation. The program then outputs the time in 24-hour notation. Your program must contain three exception classes: invalidHr, invalidMin, and invalidSec. If the user enters an invalid value for hours, then the program should throw and catch an invalidHr object. Follow similar conventions for the invalid values of minutes and seconds. This needs to be done in C++ There needs to be a separate header file for each...
Write a program that prompts the user to enter an integer number between 1 and 999....
Write a program that prompts the user to enter an integer number between 1 and 999. The program displays the sum of all digits in the integer if the input is valid; otherwise, it displays a message indicating that the integer is not between 1 and 999 and hence, is invalid. Name the program file Q1.cpp Example: if the user enters 12, sum of digits is 3. If the user enters 122, sum of digits is 5.
Write a C program that prompts the user to enter a line of text on the...
Write a C program that prompts the user to enter a line of text on the keyboard then echoes the entire line. The program should continue echoing each line until the user responds to the prompt by not entering any text and hitting the return key. Your program should have two functions, writeStr and readLn, in addition to the main function. The text string itself should be stored in a char array in main. Both functions should operate on NUL-terminated...
Write a C++ program that: Allow the user to enter the size of the matrix such...
Write a C++ program that: Allow the user to enter the size of the matrix such as N. Call a function to do the following: Create a vector size n X n Populate the vector with n2distinct RANDOM integers.
Modify the program so that it prompts the user to enter an entire line, reads the...
Modify the program so that it prompts the user to enter an entire line, reads the line, then echoes the entire line. Read only one byte at a time from the keyboard.Explain what you did. #include int main(void) { char aLetter; write(STDOUT_FILENO, "Enter one character: ", 21); // prompt user read(STDIN_FILENO, &aLetter, 1); // one character write(STDOUT_FILENO, "You entered: ", 13); // message write(STDOUT_FILENO, &aLetter, 1); // echo character return 0; }
Write a complete C program that prompts the user for the coordinates of two 3- D...
Write a complete C program that prompts the user for the coordinates of two 3- D points ( x1 , y1 , z1 ) and ( x2 , y2 , z2 ) and displays the distance between them computed using the following formula: distance= square root of (x1-x2)2+(y1-y2)2+(z1-z2)2
PLease code a C++ program that prompts a user to enter 10 numbers. this program should...
PLease code a C++ program that prompts a user to enter 10 numbers. this program should read the numbers into an array and find the smallest number in the list, the largest numbers in the list the sum of the 10 numbers and the average of the 10 numbers please use file i/o and input measures for Handling Errors in C++ When Opening a File