# 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))

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

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

Step 3

Screenshot 2

...

### Want to see the full answer?

See Solution

#### 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