A Beginner's Guide to D/Conditions and Loops/The Concepts of Conditionals and Loops


At this point, you should know how to do some simple interaction with the user. But without conditions or loops, your programs can only follow one simple pattern.

One fundamental capability of any programming language is conditions. A condition statement, such as an if statement, causes different code to run depending on whether a condition is true or false. if statements will be introduced in the following section.

Another important ability is a loop. It's often necessary to make one section of code run multiple times. The foreach, for and while loops allow this. They will be introduced later in this chapter.