Using the Conditional Operator to Do Comparisons - C++ Operator

C++ examples for Operator:Conditional Operator

Description

Using the Conditional Operator to Do Comparisons

Demo Code

#include <iostream>
#include <string>
using namespace std;

int main()//  w  w  w. j  a  va2 s. co m
{
  int first = 10;
  int second = 20;
  string result;
  result = first == second ? "equal" : "not equal";
  cout << result << endl;
  return 0;
}

Result


Related Tutorials