C Tutorial/Statement/Control Structures


Deprecated: Constant E_STRICT is deprecated in /var/www/cppe.ru/www/includes/exception/MWExceptionHandler.php on line 179

Deprecated: Creation of dynamic property PPDStack::$accum is deprecated in /var/www/cppe.ru/www/includes/parser/Preprocessor_DOM.php on line 803

Deprecated: Constant E_STRICT is deprecated in /var/www/cppe.ru/www/includes/exception/MWExceptionHandler.php on line 179

Deprecated: Constant E_STRICT is deprecated in /var/www/cppe.ru/www/vendor/mediawiki/at-ease/src/Functions.php on line 48
Материал из C\C++ эксперт
Перейти к: навигация, поиск

Control Structures

Control structures: sequential, selection, iteration and encapsulation.

A sequential structure is one in which instructions are executed in sequence. For example,


# include<stdio.h>
main()
{
    int i=0, j =1;
    printf("A");
    i = i + 1;
    printf("B");
    j = j + 1;
    printf("C");
}
ABC

Selection structure

The sequence of the instruction is determined by the condition.

The statements in this category are if and switch.


# include<stdio.h>
main(){
    int i=0, j =1;
   
    if (i > j){
        i = i + 1;
        printf("a");
    }
    else{
        printf("b");
        j = j +1;
    }
}
b