Pages2

Friday, March 4, 2011

CONDITIONAL OPERATORS

if(expression) {

... //

... // operation1

...}//

else

operation2

switch (selector)           // Selector is of char or int type
{
    case constant1:
        operation1         // Group of operators are executed if
        ...                // selector and constant1 are equal
        break;
    case constant2: 
        operation2         // Group of operators are executed if
        ...                // selector and constant2 are equal
        break;
        ...
    default:
        expected_operation // Group of operators are executed if no
        ...                // constant is equal to selector
        break;
}

while(expression){
    commands
    ...
}

while(1){
    ... // Expressions enclosed within curly brackets will be
    ... // endlessly executed (endless loop).
}

for(initial_expression; condition_expression; change_expression) {
    operations
    ...
}

a = 0; // Set initial value
 
do
 
a = a+1 // Operation in progress
 
while (a <= 1E06); // Check condition

No comments:

Post a Comment