Search This Blog

Friday, 14 June 2013

Weird behavior from C++ compiler

#include <iostream.h>

typedef int Bool;

const Bool TRUE = 1;
const Bool FALSE = 0;

void main () {

  int zero = 0;
  int two = 2;
  int three = 3;

  cout << (FALSE && (1/zero == 5)) << endl;
  cout << ((1/zero == 5) && FALSE) << endl;
  cout << ((1/zero == 5) && (two == three)) << endl;
}

Output:

0
0
Floating exception

No comments:

Post a Comment