_Imaginary

if

The if keyword allows a course of action to be based on the outcome of a condition. The general form of the if statement is

 if(condition) {     statement block 1 } else {     statement block 2 }

If single statements are used, the braces are not needed. The else is optional.

The condition may be any expression. If that expression evaluates to true (any value other than zero), then statement block 1 will be executed; otherwise, if it exists, statement block 2 will be executed.

The following fragment checks if x is greater than 10:

if(x > 10)   cout << "x is greater than 10."; else   cout << "x is less than or equal to 10.";




C(s)C++ Programmer's Reference
C Programming on the IBM PC (C Programmers Reference Guide Series)
ISBN: 0673462897
EAN: 2147483647
Year: 2002
Pages: 539

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net