Question
Asked Jan 20, 2020
14 views

Use de-morgans laws to write the equivlant expressions of each of the following and then write a program to show that both the original expression and the new expression in each case are equivlant. Write in C programming language  

a)    !(x< 5) && !(y>=7)

b)    !(a==b) || !(g != 5)

c)    !((x<=8) && (y> 4))

d)   !(( i > 4) || !(j<=6))

check_circle

Expert Answer

Step 1

The following is source code for the above question in C programming language. Also, the comments have been added in the source code itself to have a better understanding of the code.

 

Source Code

//include the header files

#include<stdio.h>

#include <conio.h>

//define the main function

int main()

{

    //declare the required variables

    int x = 9, y = 2,a = 4,b = 4, g = 5, i = 3, j = 10;

    //display the values of the variables declared

    printf( "The current variable values are: ");

    printf( "x = %d, y = %d, a = %d, b = %d ", x, y, a, b);

    printf( "g = %d, y = %d, i = %d, j = %d ", g, y, i, j );

    //write the conditional statement using if else and by applying the de-morgans law

    //check the if condition and if it is true then display the if statement otherwise

    //display the else statement for each part of the question.

    if ( ( !( x < 5 ) && !( y >= 7 ) ) == ( !( ( x < 5 ) || ( y >= 7 ) ) ) )

    {

        printf( "!( x < 5 ) && !( y >= 7 ) is equivalent to !( ( x < 5 ) || ( y >= 7 ) ) " );

    }

    else

    {

    printf( "!( x < 5 ) && !( y >= 7 ) is not equivalent to !( ( x < 5 ) || ( y >= 7 ) ) " );

    }

    if ( ( !( a == b ) || !( g != 5 ) ) == ( !( ( a == b ) && ( g != 5 ) ) ) )

    {

    printf( "!( a == b ) || !( g != 5 ) is equivalent to !( ( a == b ) && ( g != 5 ) ) " );

    }

    else

    {

    printf( "!( a == b ) || !( g != 5 ) is not equivalent to !( ( a == b ) && ( g != 5 ) ) " );

    }

    if ( !( ( x <= 8 ) && ( y > 4 ) ) == ( !( x <= 8 ) || !( y > 4 ) ) )

    {

    printf( "!( ( x <= 8 ) && ( y > 4 ) ) is equivalent to ( !( x <= 8 ) || !( y > 4 ) ) " );

    }

    else

    {

    printf( "!( ( x <= 8 ) && ( y > 4 ) ) is not equivalent to ( !( x <= 8 ) || !( y > 4 ) ) ");

    }

    if ( !( ( i > 4 ) || !( j <= 6 ) ) == ( !( i > 4 ) && ( j <= 6 ) ) )

    {

    printf( "!( ( i > 4 ) || !( j <= 6 ) ) is equivalent to ( !( i > 4 ) && ( j <= 6 ) ) " );

    }

    else

    {

    printf( "!( ( i > 4 ) || !( j <= 6 ) ) is not equivalent to ( !( i > 4 ) && ( j <= 6 ) ) ");

    }

 

    getch ();

    return 0;

}

//end of main function

Step 2

Screenshot 1

Computer Science homework question answer, step 2, image 1
fullscreen
Step 3

Screenshot 2

...
Computer Science homework question answer, step 3, image 1
fullscreen

Want to see the full answer?

See Solution

Check out a sample Q&A here.

Want to see this answer and more?

Solutions are written by subject experts who are available 24/7. Questions are typically answered within 1 hour.*

See Solution
*Response times may vary by subject and question.
Tagged in

Engineering

Computer Science

Programing Language

Related Computer Science Q&A

Find answers to questions asked by student like you
Show more Q&A
add
question_answer

Q: What is beta testing?

A: Beta Testing: DefinitionA beta test is the second phase of software testing in software development ...

question_answer

Q: analyze each program and figure out what is wrong with the memory management in the code and how to ...

A: The larger input will give error “free(): invalid next size (fast)” as the statement “q = malloc(siz...

question_answer

Q: Design a 4bits combinational circuit 2’s complementer (the output generates the 2’s complement of th...

A: Truth Table which generates the 2’s compliment of input binary number is given below:

question_answer

Q: Did I correctly perform the SQL query below (photo attached): Create a query that is based on two ta...

A: The given query is performed correctly:SELECT COURSE_TITLE, COURSE_DESCRIPTION FROM COURSE INNER JOI...

question_answer

Q: What is an example of a query that is based on the tables (attached)  and includes both an arithmeti...

A: Query:SELECT COURSE.COURSE_TITLE, COURSE.COURSE_DESCRIPTION, COURSE.COURSE_TYPE_CODE FROM COURSE INN...

question_answer

Q: Write a program that reads a list of words. Then, the program outputs those words and their frequenc...

A: Program:#print the statementprint ("Enter the input:") #get the input and store it a variablesentenc...

question_answer

Q: What are features of Unified Communications Systems? How do they benefit the businesses that deploy ...

A: The unified Communication system is a type of business-class platform that combines all the latest d...

question_answer

Q: Hi, I am programming in java. The instructions require: Create a new project and call it Project8. C...

A: All the changes are commented above the modified or added line.In main() method Mymethod() called an...

question_answer

Q: In C++: Explain and show how to use the recursive function int gcd (inta, int b).

A: C++ Source Code//include the required header file#include&lt;iostream&gt;using namespace std;//Decla...