Learn More

Thursday, December 1, 2011

Group Of If Structure

Every living being constructed by a simple cell, including brain cells. Way of thinking humans are also starting from the simplest things. In programming, all control programs comes from the simple logic. For that reason, this post will discuss about the control structure, "if structure". The structure of this control is indispensable in making games, including 2D games.

If Structure

The structure of this condition aims to choose between two options, under certain conditions. One option would be selected if it meets certain conditions. For example, A has a black color, while B has a red color, but we want to choose the color red. Then B will be selected. In the c++, this structure has the following form


consider the following example 

if structure result

If-else Structure

This structure is basically not much different from if structure. The difference is structure if-else may contain more detailed requirements than if structure. For example, suppose that A and B are the mangoes of the same type. However, the mango has a yellow color to be selected. So in this case, if-else structure more suitable than if the structure. Consider the form of if-else structure


consider the following example

if-else structure result

If-else-if Structure

This structure is the development of the structure of if-else and if. Suppose we want to buy a batik from the town of Pamulang in Jakarta. However, it is possible if batik from Pamulang is not available. So an alternative is batik from Yogyakarta. But, batik from Yogyakarta city should be green. In this case, the structure of if-else-if is to be used. Consider the form of this structure

consider the following example

if-else-if result

Post a Comment