Skip to content

Latest commit

 

History

History
25 lines (18 loc) · 517 Bytes

5.7.md

File metadata and controls

25 lines (18 loc) · 517 Bytes

(a)

if (ival1 != ival2)
  ival1 = ival2;  // Missing semicolon
else ival1 = ival2 = 0;

(b)

if (ival < minval) {  // Need a block for more than one statements
  minval = ival;
  occurs = 1;
}

(c)

int ival;  // Used outside the first if scope, thus defined outside
if (ival = get_value())
  cout << "ival = " << ival << endl;
if (!ival)
  cout << "ival = 0\n";

(d)

if (ival == 0)  // Should be equality operator instead of assignment
  ival = get_value();