A Demonstration of Branching Based on Relational Operators : relational and logical operators « Operators statements « C++ Tutorial






#include <iostream>
int main()
{
   using std::cout;
   using std::cin;

   int i, i2;
   cout << "Enter the score for the Mets: ";
   cin >> i;

   cout << "\nEnter the score for the Yankees: ";
   cin >> i2;

   if (i > i2)
      cout << "Go i!\n";

   if (i < i2)
   {
      cout << "Go i2!\n";
   }

   if (i == i2)
   {
      cout << "A tie?\n";
      cout << "Give me the real score for the i2: ";
      cin >> i2;

      if (i > i2)
         cout << "i";

      if (i2 > i)
         cout << "i2";

      if (i2 == i)
         cout << "tie!";
   }
   return 0;
}








3.2.relational and logical operators
3.2.1.The relational and logical operators
3.2.2.Use And operator to connect two boolean expressions
3.2.3.Logical operator keywords: and, or, not, not_eq
3.2.4.Create an XOR using the C++ logical operators.
3.2.5.Output the results of several variable comparisons.
3.2.6.A Demonstration of Branching Based on Relational Operators