Why C++ Supports Several Control Structures
C++ supports three main control structures namely, sequential structure, selection structure, and repetition structure. The structure enables the programmer to specify the sequence in which the code is to be executed. Originally, C++ follows a sequential structure. Meaning that the codes are executed in the order of appearance one line after the other. For instance in the piece of code below, cout << “ Input your username” will be executed before the program accepts the username entry using the line cin >> username;
cout << “ Input your username”
cin >> username;
However, for such a program to make sense, it needs to get the username and validate it. The validation requires usage of selection structure. In this case, usage if statement. If the username is correct, cout << “Correct usernamer”;. Otherwise the code after else, cout << “Wrong usernamer”; will be executed.
Delegate your assignment to our experts and they will do the rest.