I have to do a code in De Morgans law show that 2 expressions are equivalent. I not even sure if I am going in the right direction. Can somebody steer me right

original expression - ! ( x < 5 ) && ( y >= 7 )
De morgans law expressin - ( x > = 5 || ( y < 7 )

#include <iostream>
using std::cout;
using std::endl;



int main() 
{ 
    int x = 4;
    int y = 8;
    
    if ( ! ( x < 5 ) && ( y >= 7 )
    cout << "The expression is False." <<endl;
    else ( x > = 5 || ( y < 7 ) 
    cout << "The expressions are equivalent." <<endl;
    
    
    
    
}

at the very least, you have to have an equal number of open parentheses and close parentheses '(' and ')' in any given statement.

and if youre going to have a conditional after "else", then it needs to be "else if" ... which then presumes another statement to follow for "else", otherwise you could have a condition where neither statements are true.

I have to do a code in De Morgans law show that 2 expressions are equivalent. I not even sure if I am going in the right direction. Can somebody steer me right

original expression - ! ( x < 5 ) && ( y >= 7 )
De morgans law expressin - ( x > = 5 || ( y < 7 )

#include <iostream>
using std::cout;
using std::endl;



int main() 
{ 
    int x = 4;
    int y = 8;
    
    if ( ! ( x < 5 ) && ( y >= 7 )
    cout << "The expression is False." <<endl;
    else ( x > = 5 || ( y < 7 ) 
    cout << "The expressions are equivalent." <<endl;
    
    
    
    
}

Do you mind showing me an example of using de morgans law since I am a beginner.

Do you mind showing me an example of using de morgans law since I am a beginner.

(A && B) = ((A') || (B'))'

A and B are anything that can be true or false. ' is the "complement" operator in math. If A is true, A' is false. If A is false, A' is true. && is "AND", which would be the intersection in math notation. || is "OR" and is the union. So define A and B to be boolean values. Look at the above equation and write code to evaluate both sides of the equation and they should give the same results.

#include <iostream>
using namespace std;

int main ()
{
     bool A, B, AComp, BComp;

     // assign values to A and B.
     // assign values of AComp and BComp that are
     // oppostite of A and B.

     bool comparison1 = A && B;

     bool comparison2 = // code for right side of equation.

     // compare comparison1 and comparison2.  They
     // should be the same for all values of A and B.

     return 0;
}
bool comparison1 = (!(x < 5 ) && ! ( y >= 7 )
bool comparison2 = (x >= 5 ) || ( y < 7 )

As jephthah mentioned, you need to match the starting and closing parentheses. Count them. You need to have the same number of starting and closing parentheses. It doesn't make any sense otherwise. Also, the comparsion inside your inner parentheses should be the same to cut down on confusion. You're changing them from:

x < 5 to x >= 5

and

y >= 7 to y < 7

Make them opposite with the ! operator rather than actually changing the contents of the inner comparison, as in:

bool comparison1 = (x < 5 ) &&  ( y >= 7 );
    bool comparison2 = !(!(x < 5 ) || !(y >= 7));  
    
    if (comparison1 != comparison2)
         cout << "Something is wrong!" << endl;

"Something is wrong!" should never display regardless of the values of x and y. Note that the comparisons inside the inside parentheses are the same and that the number of opening and closing parentheses are the same in each line.

Sorry for asking so many questions

I am getting a few errors that say:

In function `int main()  ( 1 error)
expected `,' or `;' before "bool"  ( 1 error)
expected `,' or `;' before '{' token ( 4 errors)
expected `}' at end of input (1 error)



#include <iostream>
using namespace std;
using std::boolalpha;
using std::cout;
int main ()
{
bool  comparison1, comparison2, comparison3, comparison4, comparison5, comparison6,
comparison7, comparison8;   
int x = 4;
int y = 8;
int a = 5;
int b = 6;
int g = 2;
int i = 3;
int j = 7;     

   {  bool comparison1 = (x >= 5 ) || ( y < 7 )
      bool comparison2 = (!(x < 5 ) && ! ( y >= 7 )
      if (comparison1 != comparison2)
    }  cout << "Something is wrong!" << endl;  

    {  bool comparison3 = ( x >= 5 ) || ( y < 7 ) 
      bool comparison4 = ( ! ( a == b ) || ! ( g != 5 )
      if (comparison3 != comparison4)
      }   cout << "Something is wrong!" << endl;  

    {  bool comparison5 =  (x > 8 ) || ( y <= 4 )
      bool comparison6 =  ( ! ( x <= 8 ) && ( y > 4 )
      if (comparison5 != comparison6)
     } cout << "Something is wrong!" << endl;  

    {  bool comparison7 = ( i <= 4 ) && ( j > 6 )
      bool comparison8 = (! ( i > 4 ) || ( j <= 6 )
      if (comparison7 != comparison8)
     } cout << "Something is wrong!" << endl;  
{    
     return 0;
}
}
}
}

Too many brackets, not enough semicolons. Every complete statement needs a semicolon at the end. The beginnings of loops and if-statements don't have semicolons at the end of the line, but just about everything else does. Use code tags and indentation:

[code=cplusplus] // paste your code here

[/code]
This adds syntax highlighting, line numbers, and preserves formatting. If you want to copy and paste, to get rid of line numbers, click on "Toggle Plain Text". Here is your code cleaned up. Brackets are like parentheses. For every starting bracket, you need an ending bracket.

#include <iostream>
using namespace std;
using std::boolalpha;
using std::cout;
int main ()
{
	bool comparison1, comparison2, comparison3, comparison4,
             comparison5, comparison6, comparison7, comparison8;
	int x = 4;
	int y = 8;
	int a = 5;
	int b = 6;
	int g = 2;
	int i = 3;
	int j = 7;


	bool comparison1 = (x >= 5 ) || ( y < 7 );
	bool comparison2 = (!(x < 5 ) && ! ( y >= 7 );
	if (comparison1 != comparison2)
		cout << "Something is wrong!" << endl;

	bool comparison3 = ( x >= 5 ) || ( y < 7 );
	bool comparison4 = ( ! ( a == b ) || ! ( g != 5 );
	if (comparison3 != comparison4)
		cout << "Something is wrong!" << endl;

	bool comparison5 = (x > 8 ) || ( y <= 4 );
	bool comparison6 = ( ! ( x <= 8 ) && ( y > 4 );
	if (comparison5 != comparison6)
		cout << "Something is wrong!" << endl;

	bool comparison7 = ( i <= 4 ) && ( j > 6 );
	bool comparison8 = (! ( i > 4 ) || ( j <= 6 );
	if (comparison7 != comparison8)
		cout << "Something is wrong!" << endl;

	return 0;
}

If you wanted to add brackets to an if statement like this:

if (comparison7 != comparison8)
		cout << "Something is wrong!" << endl;

you could do this:

if (comparison7 != comparison8)
        {
		cout << "Something is wrong!" << endl;
        }

The two statements above are equivalent.

You still have the same problems you did before in a lot of lines. See my previous post. Keep the comparisons the same and invert with the ! operator to take the complement rather than changing the internal comparison itself, and each comparison needs to have the same number of starting and ending parentheses.

I finally got it.. Thanks for everyones help!!

I don't understand how to get into plain text but here is my code...My teacher told me to put my logic for comparing the expressions should look more like this: Does this look right??

 if ( ( !( x < 5 ) && !( y >= 7 ) ) ==  ( !( ( x < 5 ) || ( y >= 7 ) ) ) )
            cout << "!(x < 5) && !(y >= 7) is equivalent to"   << " !((x < 5) || (y >= 7))" << endl;
  else 
            cout << "!(x < 5) && !(y >= 7) is not equivalent to"   << " !((x < 5) || (y >= 7))" << 



#include <iostream>
using namespace std;
using std::boolalpha;
using std::cout;
int main ()
{
bool  comparison1, comparison2, comparison3, comparison4, comparison5, comparison6,
comparison7, comparison8;   
int x = 4;
int y = 8;
int a = 5;
int b = 6;
int g = 2;
int i = 3;
int j = 7;




   {   bool comparison1 = (x >= 5 ) || ( y < 7 );
      bool comparison2 = !(x < 5 ) && ! ( y >= 7 );
       if  ( !( x < 5 ) && !( y >= 7 ) ) ==   (! ( x < 5 ) || ( y >= 7 ) ) ) )
            cout << "!(x < 5) && !(y >= 7) is equivalent to"   << " !((x < 5) || (y >= 7))" << endl;
  elselse
            cout << "!(x < 5) && !(y >= 7) is not equivalent to"   << " !((x < 5) || (y >= 7))" << endl;


      bool comparison3 = ( a ! = b ) && ( g == 5 )
      bool comparison4 = (!(a = = b ) || ! ( g ! = 5 )
      if (!(a = = b ) || ! ( g ! = 5 ) ) == (! (a ==b ) && ( g ! = 5 )
      cout << "!(a = = b) || !(g ! = 5 ) is equivalent to" << "!(a = = b) &&  ! (g ! = 5 ))" << endl;
      else
      cout << " !(a = = b) || !(g ! = 5 ) is not equivalent to" << "!(a = = b) && ! (g ! = 5 )" endl;

      }   
      bool comparison5 =  (x > 8 ) || ( y <= 4 );
      bool comparison6 =  ! ( x <= 8 ) && ( y > 4 );
      if  (! ( x <= 8 ) && ( y > 4 ) = =  (! ( x <= 8 ) || ( y > 4 ) ) ) )
          cout << "!(X <= 8) && ( y > 4 ) is equivalent to" << " ! (( x <= 8 || ( y > 4 ))" << endl;
      else
          cout << "!(X <= 8) && ( y > 4 ) is not equivalent to" << " ! (( x <= 8 || ( y > 4 ))" <<endl;
      {
           }
      bool comparison7 = ( i <= 4 ) && ( j > 6 );
      bool comparison8 = ! ( i > 4 ) || ( j <= 6 );
      if ( ! ( i > 4 ) || ( j < = 6 ) = = ( ! ( i > 4 ) && ( j < = 6 ) ) ) )
         cout "!(i > 4 ) || ( j <= 6 ) is equivalent to" << " !(( i >4 && ( j <= 6))" << endl;
      else
      cout << "!(i > 4 ) || ( j <= 6 ) is not equivalent to" << " (( i > 4 && ( j <= 6))" << endl;
}
     return 0;
}
}

Can anyone fix my bracket problem I have to turn it in less than 2 hours... Thanks

#include <iostream>
using namespace std;
using std::boolalpha;
using std::cout;
int main ()
{
bool comparison1, comparison2, comparison3, comparison4, comparison5, comparison6,
comparison7, comparison8;
int x = 4;
int y = 8;
int a = 5;
int b = 6;
int g = 2;
int i = 3;
int j = 7;




{ bool comparison1 = (x >= 5 ) || ( y < 7 );
bool comparison2 = !(x < 5 ) && ! ( y >= 7 );
if ((!(x <  5 ) && !( y >= 7 ) ) == (! (( x < 5 ) || ( y >= 7 )))) 
{
cout << "!(x < 5) && !(y >= 7) is equivalent to" << " !((x < 5) || (y >= 7))" << endl;
}
else{

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

{bool comparison3 = ( a ! = b ) && ( g == 5 ); 
bool comparison4 = (!(a = = b ) || ! ( g ! = 5 );
if ((!(a = = b ) || ! ( g ! = 5 ) ) == (! ((a= =b ) && ( g ! = 5 ))))
{
cout << "!(a = = b) || !(g ! = 5 ) is equivalent to" << "!(a = = b) && ! (g ! = 5 ))" << endl;
}
else 
{
cout << " !(a = = b) || !(g ! = 5 ) is not equivalent to" << "!(a = = b) && ! (g ! = 5 )" endl;
}

{bool comparison5 = (x > 8 ) || ( y <= 4 );

bool comparison6 = ! ( x <= 8 ) && ( y > 4 );
if ( ( ! (x <= 8 ) && ( y > 4 ) = = (! (( x <= 8 ) || ( y > 4 ) ) ) )
{
cout << "!(x <= 8) && ( y > 4 ) is equivalent to" << " !(x <= 8 || ( y > 4 ))" << endl;
}
else{ 

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

{ bool comparison7 = ( i <= 4 ) && ( j > 6 );
bool comparison8 = ! ( i > 4 ) || ( j <= 6 );
if ( (! ( i > 4 ) || ( j < = 6 ) = = ( !( ( i > 4 ) && ( j < = 6 ) ) ) )
{
cout "!(i > 4 ) || ( j <= 6 ) is equivalent to" << " !( i >4 && ( j <= 6))" << endl;
}
else{ 

cout << "!(i > 4 ) || ( j <= 6 ) is not equivalent to" << " !( i > 4 && ( j <= 6))" << endl;
}
return 0;
}
}
}
}  
}

you know it's damn near impossible to read code like that.

is it really too much to ask for you to put the code tags in there? you type right over the instructions everytime you post.

#include <iostream> using namespace std; using std::boolalpha; using std::cout; int main () { bool comparison1, comparison2, comparison3, comparison4, comparison5, comparison6, comparison7, comparison8; int x = 4; int y = 8; int a = 5; int b = 6; int g = 2; int i = 3; int j = 7;

{ bool comparison1 = (x >= 5 ) || ( y < 7 ); bool comparison2 = !(x < 5 ) && ! ( y >= 7 ); if ((!(x < 5 ) && !( y >= 7 ) ) == (! (( x < 5 ) || ( y >= 7 )))) { cout << "!(x < 5) && !(y >= 7) is equivalent to" << " !((x < 5) || (y >= 7))" << endl; } else{

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

{bool comparison3 = ( a ! = b ) && ( g == 5 ); bool comparison4 = (!(a = = b ) || ! ( g ! = 5 ); if ((!(a = = b ) || ! ( g ! = 5 ) ) == (! ((a= =b ) && ( g ! = 5 )))) { cout << "!(a = = b) || !(g ! = 5 ) is equivalent to" << "!(a = = b) && ! (g ! = 5 ))" << endl; } else { cout << " !(a = = b) || !(g ! = 5 ) is not equivalent to" << "!(a = = b) && ! (g ! = 5 )" endl; }

{bool comparison5 = (x > 8 ) || ( y <= 4 );

bool comparison6 = ! ( x <= 8 ) && ( y > 4 ); if ( ( ! (x <= 8 ) && ( y > 4 ) = = (! (( x <= 8 ) || ( y > 4 ) ) ) ) { cout << "!(x <= 8) && ( y > 4 ) is equivalent to" << " !(x <= 8 || ( y > 4 ))" << endl; } else{

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

{ bool comparison7 = ( i <= 4 ) && ( j > 6 ); bool comparison8 = ! ( i > 4 ) || ( j <= 6 ); if ( (! ( i > 4 ) || ( j < = 6 ) = = ( !( ( i > 4 ) && ( j < = 6 ) ) ) ) { cout "!(i > 4 ) || ( j <= 6 ) is equivalent to" << " !( i >4 && ( j <= 6))" << endl; } else{

cout << "!(i > 4 ) || ( j <= 6 ) is not equivalent to" << " !( i > 4 && ( j <= 6))" << endl; } return 0; } } } } /code[code=c]
#include <iostream>
using namespace std;
using std::boolalpha;
using std::cout;
int main ()
{
bool comparison1, comparison2, comparison3, comparison4, comparison5, comparison6,
comparison7, comparison8;
int x = 4;
int y = 8;
int a = 5;
int b = 6;
int g = 2;
int i = 3;
int j = 7;


{ bool comparison1 = (x >= 5 ) || ( y < 7 );
bool comparison2 = !(x < 5 ) && ! ( y >= 7 );
if ((!(x < 5 ) && !( y >= 7 ) ) == (! (( x < 5 ) || ( y >= 7 ))))
{
cout << "!(x < 5) && !(y >= 7) is equivalent to" << " !((x < 5) || (y >= 7))" << endl;
}
else{

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

{bool comparison3 = ( a ! = b ) && ( g == 5 );
bool comparison4 = (!(a = = b ) || ! ( g ! = 5 );
if ((!(a = = b ) || ! ( g ! = 5 ) ) == (! ((a= =b ) && ( g ! = 5 ))))
{
cout << "!(a = = b) || !(g ! = 5 ) is equivalent to" << "!(a = = b) && ! (g ! = 5 ))" << endl;
}
else
{
cout << " !(a = = b) || !(g ! = 5 ) is not equivalent to" << "!(a = = b) && ! (g ! = 5 )" endl;
}

{bool comparison5 = (x > 8 ) || ( y <= 4 );

bool comparison6 = ! ( x <= 8 ) && ( y > 4 );
if ( ( ! (x <= 8 ) && ( y > 4 ) = = (! (( x <= 8 ) || ( y > 4 ) ) ) )
{
cout << "!(x <= 8) && ( y > 4 ) is equivalent to" << " !(x <= 8 || ( y > 4 ))" << endl;
}
else{

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

{ bool comparison7 = ( i <= 4 ) && ( j > 6 );
bool comparison8 = ! ( i > 4 ) || ( j <= 6 );
if ( (! ( i > 4 ) || ( j < = 6 ) = = ( !( ( i > 4 ) && ( j < = 6 ) ) ) )
{
cout "!(i > 4 ) || ( j <= 6 ) is equivalent to" << " !( i >4 && ( j <= 6))" << endl;
}
else{

cout << "!(i > 4 ) || ( j <= 6 ) is not equivalent to" << " !( i > 4 && ( j <= 6))" << endl;
}
return 0;
}
}
}
}
/code

I'm sorry its just not working for me.. I know your frustration!

you need to end the code with

(/code)

i cant put both set of tags in one post or

the tags disappear and turn the code into highlighted code

like that

your problem boils down to one major defect. you are putting TOO MANY OF ONE TYPE OF PARENTHESIS, WITHOUT HAVING A MATCHING AMOUNT OF THE OTHER TYPE

look.... do you think this is correct?

( ! ( here is a parenthetical expression ) ) ) ) ) ) )

no? why not?

because maybe ive got 2 opening parentheses, and 7 close parentheses? does that look right to you? no? well thats what you're doing.

and thats is why your code isnt working. well, maybe there are additional problems, but we'll never be able to tell until you start tagging your code to make it readable.

i dont know how to explain it any better than this[code=c] tagging your code to make it readable.

i dont know how to explain it any better than this

#include <iostream>
using namespace std;
using std::boolalpha;
using std::cout;
int main ()
{
bool comparison1, comparison2, comparison3, comparison4, comparison5, comparison6,
comparison7, comparison8;
int x = 4;
int y = 8;
int a = 5;
int b = 6;
int g = 2;
int i = 3;
int j = 7;




{ bool comparison1 = (x >= 5 ) || ( y < 7 );
bool comparison2 = !(x < 5 ) && ! ( y >= 7 );
if ((!(x < 5 ) && !( y >= 7 ) ) == (! (( x < 5 ) || ( y >= 7 ))))
{
cout << "!(x < 5) && !(y >= 7) is equivalent to" << " !((x < 5) || (y >= 7))" << endl;
}
else{

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

{bool comparison3 = ( a ! = b ) && ( g == 5 );
bool comparison4 = (!(a = = b ) || ! ( g ! = 5 );
if ((!(a = = b ) || ! ( g ! = 5 ) ) == (! ((a= =b ) && ( g ! = 5 ))))
{
cout << "!(a = = b) || !(g ! = 5 ) is equivalent to" << "!(a = = b) && ! (g ! = 5 ))" << endl;
}
else
{
cout << " !(a = = b) || !(g ! = 5 ) is not equivalent to" << "!(a = = b) && ! (g ! = 5 )" endl;
}

{bool comparison5 = (x > 8 ) || ( y <= 4 );

bool comparison6 = ! ( x <= 8 ) && ( y > 4 );
if ( ( ! (x <= 8 ) && ( y > 4 ) = = (! (( x <= 8 ) || ( y > 4 ) ) ) )
{
cout << "!(x <= 8) && ( y > 4 ) is equivalent to" << " !(x <= 8 || ( y > 4 ))" << endl;
}
else{

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

{ bool comparison7 = ( i <= 4 ) && ( j > 6 );
bool comparison8 = ! ( i > 4 ) || ( j <= 6 );
if ( (! ( i > 4 ) || ( j < = 6 ) = = ( !( ( i > 4 ) && ( j < = 6 ) ) ) )
{
cout "!(i > 4 ) || ( j <= 6 ) is equivalent to" << " !( i >4 && ( j <= 6))" << endl;
}
else{

cout << "!(i > 4 ) || ( j <= 6 ) is not equivalent to" << " !( i > 4 && ( j <= 6))" << endl;
}
return 0;
}
}
}
}
#include <iostream>
using namespace std;
using std::boolalpha;
using std::cout;
int main ()
{
bool comparison1, comparison2, comparison3, comparison4, comparison5, comparison6,
comparison7, comparison8;
int x = 4;
int y = 8;
int a = 5;
int b = 6;
int g = 2;
int i = 3;
int j = 7;




{ bool comparison1 = (x >= 5 ) || ( y < 7 );
bool comparison2 = !(x < 5 ) && ! ( y >= 7 );
if ((!(x < 5 ) && !( y >= 7 ) ) == (! (( x < 5 ) || ( y >= 7 ))))
{
cout << "!(x < 5) && !(y >= 7) is equivalent to" << " !((x < 5) || (y >= 7))" << endl;
}
else{

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

{bool comparison3 = ( a ! = b ) && ( g == 5 );
bool comparison4 = (!(a = = b ) || ! ( g ! = 5 );
if ((!(a = = b ) || ! ( g ! = 5 ) ) == (! ((a= =b ) && ( g ! = 5 ))))
{
cout << "!(a = = b) || !(g ! = 5 ) is equivalent to" << "!(a = = b) && ! (g ! = 5 ))" << endl;
}
else
{
cout << " !(a = = b) || !(g ! = 5 ) is not equivalent to" << "!(a = = b) && ! (g ! = 5 )" endl;
}

{bool comparison5 = (x > 8 ) || ( y <= 4 );

bool comparison6 = ! ( x <= 8 ) && ( y > 4 );
if ( ( ! (x <= 8 ) && ( y > 4 ) = = (! (( x <= 8 ) || ( y > 4 ) ) ) )
{
cout << "!(x <= 8) && ( y > 4 ) is equivalent to" << " !(x <= 8 || ( y > 4 ))" << endl;
}
else{

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

{ bool comparison7 = ( i <= 4 ) && ( j > 6 );
bool comparison8 = ! ( i > 4 ) || ( j <= 6 );
if ( (! ( i > 4 ) || ( j < = 6 ) = = ( !( ( i > 4 ) && ( j < = 6 ) ) ) )
{
cout "!(i > 4 ) || ( j <= 6 ) is equivalent to" << " !( i >4 && ( j <= 6))" << endl;
}
else{

cout << "!(i > 4 ) || ( j <= 6 ) is not equivalent to" << " !( i > 4 && ( j <= 6))" << endl;
}
return 0;
}
}
}
} 

oh no... i just noticed the brackets.

you can not just arbitrary start dropping brackets anywhere you feel like.

how did you ever get this far?


.......... deep breath.


okay. good try with the code tags.

remember:

[opentag=c]
stuff in the middle
[/closetag]

close tag needs a slash "/"

but the code tags do not help much if you dont properly indent your code. can you read what you've written there? how can you ever make sense of anything if it all blurs together in a jumbly way like that?

i hope you use indents when you write code, and that this is just cut-and-paste problems.

when you copy and paste your code in between the [code] tags, be sure to copy it from your editor where you wrote it, along with the indentations.

[opentag=cpp]
#include <iostream>
using namespace std;
using std::boolalpha;
using std::cout;
int main ()
{
bool comparison1, comparison2, comparison3, comparison4, comparison5, comparison6,
comparison7, comparison8;
int x = 4;
int y = 8;
int a = 5;
int b = 6;
int g = 2;
int i = 3;
int j = 7;


{ bool comparison1 = (x >= 5 ) || ( y < 7 );
bool comparison2 = !(x < 5 ) && ! ( y >= 7 );
if ((!(x < 5 ) && !( y >= 7 ) ) == (! (( x < 5 ) || ( y >= 7 ))))
{
cout << "!(x < 5) && !(y >= 7) is equivalent to" << " !((x < 5) || (y >= 7))" << endl;
}
else{

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

{bool comparison3 = ( a ! = b ) && ( g == 5 );
bool comparison4 = (!(a = = b ) || ! ( g ! = 5 );
if ((!(a = = b ) || ! ( g ! = 5 ) ) == (! ((a= =b ) && ( g ! = 5 ))))
{
cout << "!(a = = b) || !(g ! = 5 ) is equivalent to" << "!(a = = b) && ! (g ! = 5 ))" << endl;
}
else
{
cout << " !(a = = b) || !(g ! = 5 ) is not equivalent to" << "!(a = = b) && ! (g ! = 5 )" endl;
}

{bool comparison5 = (x > 8 ) || ( y <= 4 );

bool comparison6 = ! ( x <= 8 ) && ( y > 4 );
if ( ( ! (x <= 8 ) && ( y > 4 ) = = (! (( x <= 8 ) || ( y > 4 ) ) ) )
{
cout << "!(x <= 8) && ( y > 4 ) is equivalent to" << " !(x <= 8 || ( y > 4 ))" << endl;
}
else{

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

{ bool comparison7 = ( i <= 4 ) && ( j > 6 );
bool comparison8 = ! ( i > 4 ) || ( j <= 6 );
if ( (! ( i > 4 ) || ( j < = 6 ) = = ( !( ( i > 4 ) && ( j < = 6 ) ) ) )
{
cout "!(i > 4 ) || ( j <= 6 ) is equivalent to" << " !( i >4 && ( j <= 6))" << endl;
}
else{

cout << "!(i > 4 ) || ( j <= 6 ) is not equivalent to" << " !( i > 4 && ( j <= 6))" << endl;
}
return 0;
}
}
}
}
[/closetag]

Maybe I just need to give up on coding if this doesn't work for me..I feel like a JACK ASS!!

god, dude, im sorry.

i dont mean to make you feel bad

its been a long day

i made a bunch of errors when i started too

:(

look i made a bunch of errors when i started too

(code=cpp)
(code=cpp)

this is how you put code in between the code tags

(/code)
(/code)

but like i mentioned earlier, you do need to indent your code, and copy and paste code with indention directly here with the code tags.

#include <iostream> using namespace std; using std::boolalpha; using std::cout; int main () { bool comparison1, comparison2, comparison3, comparison4, comparison5, comparison6, comparison7, comparison8; int x = 4; int y = 8; int a = 5; int b = 6; int g = 2; int i = 3; int j = 7;

{ bool comparison1 = (x >= 5 ) || ( y < 7 ); bool comparison2 = !(x < 5 ) && ! ( y >= 7 ); if ((!(x < 5 ) && !( y >= 7 ) ) == (! (( x < 5 ) || ( y >= 7 )))) { cout << "!(x < 5) && !(y >= 7) is equivalent to" << " !((x < 5) || (y >= 7))" << endl; } else{

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

{bool comparison3 = ( a ! = b ) && ( g == 5 ); bool comparison4 = (!(a = = b ) || ! ( g ! = 5 ); if ((!(a = = b ) || ! ( g ! = 5 ) ) == (! ((a= =b ) && ( g ! = 5 )))) { cout << "!(a = = b) || !(g ! = 5 ) is equivalent to" << "!(a = = b) && ! (g ! = 5 ))" << endl; } else { cout << " !(a = = b) || !(g ! = 5 ) is not equivalent to" << "!(a = = b) && ! (g ! = 5 )" endl; }

{bool comparison5 = (x > 8 ) || ( y <= 4 );

bool comparison6 = ! ( x <= 8 ) && ( y > 4 ); if ( ( ! (x <= 8 ) && ( y > 4 ) = = (! (( x <= 8 ) || ( y > 4 ) ) ) ) { cout << "!(x <= 8) && ( y > 4 ) is equivalent to" << " !(x <= 8 || ( y > 4 ))" << endl; } else{

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

{ bool comparison7 = ( i <= 4 ) && ( j > 6 ); bool comparison8 = ! ( i > 4 ) || ( j <= 6 ); if ( (! ( i > 4 ) || ( j < = 6 ) = = ( !( ( i > 4 ) && ( j < = 6 ) ) ) ) { cout "!(i > 4 ) || ( j <= 6 ) is equivalent to" << " !( i >4 && ( j <= 6))" << endl; } else{

cout << "!(i > 4 ) || ( j <= 6 ) is not equivalent to" << " !( i > 4 && ( j <= 6))" << endl; } return 0; } } } }[code=cpp]
#include <iostream>
using namespace std;
using std::boolalpha;
using std::cout;
int main ()
{
bool comparison1, comparison2, comparison3, comparison4, comparison5, comparison6,
comparison7, comparison8;
int x = 4;
int y = 8;
int a = 5;
int b = 6;
int g = 2;
int i = 3;
int j = 7;


{ bool comparison1 = (x >= 5 ) || ( y < 7 );
bool comparison2 = !(x < 5 ) && ! ( y >= 7 );
if ((!(x < 5 ) && !( y >= 7 ) ) == (! (( x < 5 ) || ( y >= 7 ))))
{
cout << "!(x < 5) && !(y >= 7) is equivalent to" << " !((x < 5) || (y >= 7))" << endl;
}
else{

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

{bool comparison3 = ( a ! = b ) && ( g == 5 );
bool comparison4 = (!(a = = b ) || ! ( g ! = 5 );
if ((!(a = = b ) || ! ( g ! = 5 ) ) == (! ((a= =b ) && ( g ! = 5 ))))
{
cout << "!(a = = b) || !(g ! = 5 ) is equivalent to" << "!(a = = b) && ! (g ! = 5 ))" << endl;
}
else
{
cout << " !(a = = b) || !(g ! = 5 ) is not equivalent to" << "!(a = = b) && ! (g ! = 5 )" endl;
}

{bool comparison5 = (x > 8 ) || ( y <= 4 );

bool comparison6 = ! ( x <= 8 ) && ( y > 4 );
if ( ( ! (x <= 8 ) && ( y > 4 ) = = (! (( x <= 8 ) || ( y > 4 ) ) ) )
{
cout << "!(x <= 8) && ( y > 4 ) is equivalent to" << " !(x <= 8 || ( y > 4 ))" << endl;
}
else{

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

{ bool comparison7 = ( i <= 4 ) && ( j > 6 );
bool comparison8 = ! ( i > 4 ) || ( j <= 6 );
if ( (! ( i > 4 ) || ( j < = 6 ) = = ( !( ( i > 4 ) && ( j < = 6 ) ) ) )
{
cout "!(i > 4 ) || ( j <= 6 ) is equivalent to" << " !( i >4 && ( j <= 6))" << endl;
}
else{

cout << "!(i > 4 ) || ( j <= 6 ) is not equivalent to" << " !( i > 4 && ( j <= 6))" << endl;
}
return 0;
}
}
}
}

Hey Man.. I guess I am dumb as rocks I just can't grasp how to do it.. I appreciate your help with everything, but I cannot submit anymore replys because I only have 20 min to turn it in. I thought I had until 12. Out of all the problems a DAMN bracket problem is hold me up!! SUCKS!!

#include <iostream>
using namespace std;
using std::boolalpha;
using std::cout;
int main ()
{
	bool comparison1, comparison2, comparison3, comparison4, comparison5, comparison6,
		comparison7, comparison8;
	int x = 4;
	int y = 8;
	int a = 5;
	int b = 6;
	int g = 2;
	int i = 3;
	int j = 7;




	bool comparison1 = (x >= 5 ) || ( y < 7 );
	bool comparison2 = !(x < 5 ) && ! ( y >= 7 );
	if ((!(x < 5 ) && !( y >= 7 ) ) == (! (( x < 5 ) || ( y >= 7 ))))
	{
		cout << "!(x < 5) && !(y >= 7) is equivalent to" << " !((x < 5) || (y >= 7))" << endl;
	}
	else
	{
		cout << "!(x < 5) && !(y >= 7) is not equivalent to" << " !((x < 5) || (y >= 7))" << endl;
	}

	bool comparison3 = ( a ! = b ) && ( g == 5 );
	bool comparison4 = (!(a = = b ) || ! ( g ! = 5 );
	if ((!(a = = b ) || ! ( g ! = 5 ) ) == (! ((a= =b ) && ( g ! = 5 ))))
	{
		cout << "!(a = = b) || !(g ! = 5 ) is equivalent to" << "!(a = = b) && ! (g ! = 5 ))" << endl;
	}
	else
	{
		cout << " !(a = = b) || !(g ! = 5 ) is not equivalent to" << "!(a = = b) && ! (g ! = 5 )" endl;
	}

	bool comparison5 = (x > 8 ) || ( y <= 4 );

	bool comparison6 = ! ( x <= 8 ) && ( y > 4 );
	if ( ( ! (x <= 8 ) && ( y > 4 ) = = (! (( x <= 8 ) || ( y > 4 ) ) ) )
	{
		cout << "!(x <= 8) && ( y > 4 ) is equivalent to" << " !(x <= 8 || ( y > 4 ))" << endl;
	}
	else
	{
		cout << "!(x <= 8) && ( y > 4 ) is not equivalent to" << " !( x <= 8 || ( y > 4 ))" <<endl;
	}

	bool comparison7 = ( i <= 4 ) && ( j > 6 );
	bool comparison8 = ! ( i > 4 ) || ( j <= 6 );
	if ( (! ( i > 4 ) || ( j < = 6 ) = = ( !( ( i > 4 ) && ( j < = 6 ) ) ) )
	{
		cout "!(i > 4 ) || ( j <= 6 ) is equivalent to" << " !( i >4 && ( j <= 6))" << endl;
	}
	else
	{
		cout << "!(i > 4 ) || ( j <= 6 ) is not equivalent to" << " !( i > 4 && ( j <= 6))" << endl;
	}
	return 0;
}

Here's code tags and formatting with fewer brackets. Let's go from here.

HEY, HERE IT IS. I FIXED A LOT OF ERRORS

NOW IT WORKS... SORT OF.

I DONT THINK THE LOGIC IS EXACTLY RIGHT, BUT IT COMPILES AND RUNS

#include <iostream>
using namespace std;
using std::boolalpha;
using std::cout;
int main ()
{
   bool comparison1, comparison2, comparison3, comparison4, comparison5, comparison6, comparison7, comparison8;
   
   int x = 4;
   int y = 8;
   int a = 5;
   int b = 6;
   int g = 2;
   int i = 3;
   int j = 7;

   comparison1 = (x >= 5 ) || ( y < 7 );
   comparison2 = !(x < 5 ) && ! ( y >= 7 );
   
   if ((!(x < 5) && !(y >= 7)) == (!((x < 5) || (y >= 7))))
   {
      cout << "!(x < 5) && !(y >= 7) is equivalent to" 
         << " !((x < 5) || (y >= 7))" 
         << endl;
   }
   else{
      cout << "!(x < 5) && !(y >= 7) is not equivalent to" 
         << " !((x < 5) || (y >= 7))" 
         << endl;
   }
   
   comparison3 = (( a != b ) && ( g == 5 ));
   comparison4 = (!(a == b ) || ! ( g != 5 ));
   
   if ((!(a == b) || ! (g != 5 )) == (!(a==b ) && (g != 5)))
   {
      cout << "!(a = = b) || !(g ! = 5 ) is equivalent to" 
         << "!(a = = b) && ! (g ! = 5 ))" 
         << endl;
   }
   else
   {
      cout << " !(a = = b) || !(g ! = 5 ) is not equivalent to" 
         << "!(a = = b) && ! (g ! = 5 )" 
         << endl;
   }
   
   comparison5 = (x > 8 ) || ( y <= 4 );
   comparison6 = (! ( x <= 8 ) && ( y > 4 ));
   
   if ((!(x <= 8) && (y > 4)) == (!((x <= 8) || (y > 4))))
   {
      cout << "!(x <= 8) && ( y > 4 ) is equivalent to" 
         << " !(x <= 8 || ( y > 4 ))" 
         << endl;
   }
   else 
   {   
      cout << "!(x <= 8) && ( y > 4 ) is not equivalent to" 
         << " !( x <= 8 || ( y > 4 ))" 
         << endl;
   }
   
   comparison7 = (( i <= 4 ) && ( j > 6 ));
   comparison8 = (! ( i > 4 ) || ( j <= 6 ));
   
   if ((!(i > 4) || (j <= 6)) == (!((i > 4) && (j <= 6))))
   {
      cout << "!(i > 4 ) || ( j <= 6 ) is equivalent to" 
         << " !( i >4 && ( j <= 6))" 
         << endl;
   }
   else 
   {   
      cout << "!(i > 4 ) || ( j <= 6 ) is not equivalent to" 
         << " !( i > 4 && ( j <= 6))"
         << endl;
   }
   return 0;
}

For code tags, you can also copy and paste your code into the box, highlight it all, then press the # icon on the top of the list of icons at the top of the box. That adds:

[code]


to the top and

[/code]
to the bottom, which is how you denote code tags.

Hey man I appreciate it alot...I don't know why I always run into bracket problems every time I do a code.. But Thanks Alot..I think I am going to bed now.

Take Care

contact me tomorrow sometime when you want to try and go over what you were doing wrong. i promise i wont be such a d1ck about it. :P

your bracket problem, its fundamental, and is probably just a simple misconception you have somewhere that needs to be cleared up.

you can submit my cleaned up version of your code. it is all your code, i just removed some extra brackets and parentheses, and a few redundant bool declarations.

it runs, and the logic is all yours. i left that alone.

the output indicates that they are all "equivalent"

[jezebel@localhost cprogs]$ ./a.out
!(x < 5) && !(y >= 7) is equivalent to !((x < 5) || (y >= 7))
!(a = = b) || !(g ! = 5 ) is equivalent to!(a = = b) && ! (g ! = 5 ))
!(x <= 8) && ( y > 4 ) is equivalent to !(x <= 8 || ( y > 4 ))
!(i > 4 ) || ( j <= 6 ) is equivalent to !( i >4 && ( j <= 6))
[jezebel@localhost cprogs]$

HEY, HERE IT IS. I FIXED A LOT OF ERRORS

NOW IT WORKS... SORT OF.

I DONT THINK THE LOGIC IS EXACTLY RIGHT, BUT IT COMPILES AND RUNS

#include <iostream>
using namespace std;
using std::boolalpha;
using std::cout;
int main ()
{
   bool comparison1, comparison2, comparison3, comparison4, comparison5, comparison6, comparison7, comparison8;
   
   int x = 4;
   int y = 8;
   int a = 5;
   int b = 6;
   int g = 2;
   int i = 3;
   int j = 7;

   comparison1 = (x >= 5 ) || ( y < 7 );
   comparison2 = !(x < 5 ) && ! ( y >= 7 );
   
   if ((!(x < 5) && !(y >= 7)) == (!((x < 5) || (y >= 7))))
   {
      cout << "!(x < 5) && !(y >= 7) is equivalent to" 
         << " !((x < 5) || (y >= 7))" 
         << endl;
   }
   else{
      cout << "!(x < 5) && !(y >= 7) is not equivalent to" 
         << " !((x < 5) || (y >= 7))" 
         << endl;
   }
   
   comparison3 = (( a != b ) && ( g == 5 ));
   comparison4 = (!(a == b ) || ! ( g != 5 ));
   
   if ((!(a == b) || ! (g != 5 )) == (!(a==b ) && (g != 5)))
   {
      cout << "!(a = = b) || !(g ! = 5 ) is equivalent to" 
         << "!(a = = b) && ! (g ! = 5 ))" 
         << endl;
   }
   else
   {
      cout << " !(a = = b) || !(g ! = 5 ) is not equivalent to" 
         << "!(a = = b) && ! (g ! = 5 )" 
         << endl;
   }
   
   comparison5 = (x > 8 ) || ( y <= 4 );
   comparison6 = (! ( x <= 8 ) && ( y > 4 ));
   
   if ((!(x <= 8) && (y > 4)) == (!((x <= 8) || (y > 4))))
   {
      cout << "!(x <= 8) && ( y > 4 ) is equivalent to" 
         << " !(x <= 8 || ( y > 4 ))" 
         << endl;
   }
   else 
   {   
      cout << "!(x <= 8) && ( y > 4 ) is not equivalent to" 
         << " !( x <= 8 || ( y > 4 ))" 
         << endl;
   }
   
   comparison7 = (( i <= 4 ) && ( j > 6 ));
   comparison8 = (! ( i > 4 ) || ( j <= 6 ));
   
   if ((!(i > 4) || (j <= 6)) == (!((i > 4) && (j <= 6))))
   {
      cout << "!(i > 4 ) || ( j <= 6 ) is equivalent to" 
         << " !( i >4 && ( j <= 6))" 
         << endl;
   }
   else 
   {   
      cout << "!(i > 4 ) || ( j <= 6 ) is not equivalent to" 
         << " !( i > 4 && ( j <= 6))"
         << endl;
   }
   return 0;
}

Your solution doesn't use comparison1 through comparison8 (and the OP's teacher apparently does not want to use comparson1 through comparsion8, if I read his earlier post correctly), so those could be taken out. I originally suggested making those variables to make it more readable. The compiler couldn't care less, obviously, but I would take the comparison1 through comparison8 lines out if the they are not used and the professor doesn't want them.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.