Switch to full style
C++ code examples
Post a reply

Comparison Pitfall

Thu Nov 13, 2008 1:56 pm

Comparison Pitfall using C++
cpp code
#include <iostream>

using namespace std;

int main()
{
int a,b,c;

// Read and test three values.
cin >> a >> b >> c;

// Run some BOGUS tests.
cout << a << " < " << b << " < " << c << ": ";
if(a < b < c) cout << "Yes.";
else cout << "No.";
cout << endl;

cout << a << " == " << b << " == " << c << ": " << endl;
if(a == b == c) cout << "Yes.";
else cout << "No.";
cout << endl;

cout << a << " > " << b << " > " << c << ": " << endl;
if(a > b > c) cout << "Yes.";
else cout << "No.";
cout << endl;
}




Post a reply
  Related Posts  to : Comparison Pitfall
 Arithmetic data comparison in C#     -  
 Comparison Operators in java     -  
 Free Quality Comparison Guide to VoIP     -  
 Arithmetic data comparison and decompression java code     -  

Topic Tags

C++ Basics