it is used often in the context:
if(condition is true) {following statements will be executed};
else[meaning that if the above condition is not true] {following statements will not be executed}
for example:
if(x == 3) {cout<< "condition is true"; y=4;}
else {cout<< "condition is not true"; y=x-1}
if (condition) statement else statement;
If(condition) { if-else statement; } else { if-else statement; }
The goto statement.
Conditional execution. if (1==2) puts ("Wow, 1==2"); else puts ("No, 1<>2")
Statements. Typical usage: if (<condition>) <statement>; else <statement>;
There is no "elseif" statement in C. You can only use "else" and "if" separately. This is a good reason for switch/case/break.
If statement is single selection statement,whereas the switch statement is multiple selective.
My self Dhilib... it is a simple query. if statement is a basic control statement. mostly it used in all the languages. also in c plus plus syntax: if(test condition) { true statements; } else { false-statements; } Example: void main() { int a,b; a=54; b=65; if(a>b) { cout<<" a value is big"; } else { cout<<"b value is big"; } }
Syntax:if (expression)statement;[elsestatement;]The expression must evaluate to a boolean value, where zero is false and all non-zero values are true. The statement (including the optional else statement) may be simple or compound, and may include a nested if statement. When the expression evaluates true, the first statement is invoked. If an else statement is provided, it is only executed when the expression evaluates false. After the appropriate statement is invoked, execution passes to the statement that immediately follows the entire if statement.
The basic control structure in C++ is the if statement.
...a function call.
char x = "C"; if(char == 'C') { } else { }