oh, shit... i just noticed that. i was in such a hurry, all i could do was to get rid of brackets, parentheses, and the redundant type delcarations, so the damn thing would compile and run.

as it was, he only had 5 minutes left to submit, so part-credit is better than no-credit. we didn't have time to debug the rest

feel free to debug the logic. hes gonna have to know how to get through this one way or another before he can pass the class, i reckon....

its not my solution.

its all his code. i just got rid of brackets, parentheses, and the redundant type delcarations, so the damn thing would compile and run.

as it is, he only had 5 minutes to submit, so part-credit is better than no-credit. we didn't have time to debug the rest

feel free to debug the logic. hes gonna have to know how to get through this one way or another before he can pass the class, i reckon....

Good point.

dang it... that would have been easy enough to include, had i noticed it.....

here it is now...

#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 (comparison1 == comparison2)
   {
      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 (comparison3 == comparison4)
   {
      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 (comparison5 == comparison6)
   {
      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 (comparison7 == comparison8)
   {
      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;
}

it seems to be working mostly... one of the expressions does not evaluate as equivalent

[jezebel@localhost cprogs]$ ./a.out
!(x < 5) && !(y >= 7) is equivalent to !((x < 5) || (y >= 7))
 !(a = = b) || !(g ! = 5 ) is not 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]$

this is better...

check this out, dude, and see if you understand this.

#include <iostream>
using namespace std;
using std::boolalpha;
using std::cout;
int main ()
{
   bool comparison1, comparison2, comparison3, comparison4, comparison5, comparison6, comparison7, comparison8;
   char comp1[32], comp2[32], comp3[32], comp4[32], comp5[32], comp6[32], comp7[32], comp8[32], equivalence[32];
   
   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 );
   strcpy(comp1,"(x >= 5 ) || ( y < 7 )");
   strcpy(comp2,"!(x < 5 ) && ! ( y >= 7 )");  
   
   if (comparison1 == comparison2)
	   strcpy(equivalence," is equivalent to ");
   else
	   strcpy(equivalence," is NOT equivalent to ");  
   cout << comp1 << equivalence << comp2 << endl;
   
   comparison3 = (( a != b ) && ( g == 5 ));
   comparison4 = (!(a == b ) || ! ( g != 5 ));  
   strcpy(comp3,"(( a != b ) && ( g == 5 ))");
   strcpy(comp4,"(!(a == b ) || ! ( g != 5 ))");  
   
   if (comparison3 == comparison4)
	   strcpy(equivalence," is equivalent to ");
   else
	   strcpy(equivalence," is NOT equivalent to ");  
   cout << comp3 << equivalence << comp4 << endl;
   
   comparison5 = (x > 8 ) || ( y <= 4 );
   comparison6 = (! ( x <= 8 ) && ( y > 4 ));
   strcpy(comp5,"(x > 8 ) || ( y <= 4 )");
   strcpy(comp6,"(! ( x <= 8 ) && ( y > 4 ))");
   
   if (comparison6 == comparison5)
	   strcpy(equivalence," is equivalent to ");
   else
	   strcpy(equivalence," is NOT equivalent to ");  
   cout << comp5 << equivalence << comp6 << endl;
   
   comparison7 = (( i <= 4 ) && ( j > 6 ));
   comparison8 = (! ( i > 4 ) || ( j <= 6 ));
   strcpy(comp7,"(( i <= 4 ) && ( j > 6 ))");
   strcpy(comp8,"(! ( i > 4 ) || ( j <= 6 ))");
   
   if (comparison7 == comparison8)
	   strcpy(equivalence," is equivalent to ");
   else
	   strcpy(equivalence," is NOT equivalent to ");  
   cout << comp7 << equivalence << comp8 << endl;
   
   
   return 0;
}

heres the output

[jezebel@localhost cprogs]$ ./a.out
(x >= 5 ) || ( y < 7 ) is equivalent to !(x < 5 ) && ! ( y >= 7 )
(( a != b ) && ( g == 5 )) is NOT 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]$
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.