By dotCore
via dreamincode.net
Submitted: Nov 09 2009 / 07:09
Conditional control statements are at the very core of programming, in almost any language. The idea behind conditional control is that it allows you to control the flow of the code that is executed based on different conditions in the program, input taken from the user, the internal state of the machine the program is running on, etc. Computers are very good at doing exactly what you tell them to do, but otherwise they are really quite stupid. However, imbuing them with the ability to make decisions through the use of conditional control can make them just a wee bit smarter – they start making the decisions that you tell them to. There are three major structures related to the conditional execution of code in C/C++ - the if statement, the if-else statement, and the switch-case statement. Each will be covered here. It is also possible to use looping structures, such as for-loops and while/do-while loops to conditionally execute code. However, they are covered in another tutorial, so I will not address them here.
Add your comment