What is the value printed in the following program? Don't be misled by the assignment operators on each side of the || - C++ Operator

C++ examples for Operator:Logical Operator

Description

What is the value printed in the following program? Don't be misled by the assignment operators on each side of the ||

Demo Code

#include <iostream>
using namespace std;
int main()//from  www  .j  a  va2  s. c o m
{
   int f, g;
   g = 5;
   f = 8;
   if ((g = 25) || (f = 35))
   {
      cout << "g is " << g << " and f got changed to " << f;
   }
   return 0;
}

Result


Related Tutorials