The Programming Structure All Beginners Should Know

download.png

Learning to make the program certainly not far from the name of the basic structure of programming language, basic logic pemograman, algorithm pemograman, and others sebainnya. All of this must of course we must learn precisely and carefully because learning programming is an activity to get used to make the program, just as we get used to using the language to speak.

Learning a new language requires us to often use the language and practice it as often and as much as possible. In addition to not forget, this habituation is useful for someone to pronounce exactly the words being studied.
In addition, when a person is learning to use a new language, the person must learn to compose the right words, so that what he communicates can be perfectly communicated. This also applies to people who are learning to write the lines of the program, using the appropriate language options.

In order to use the programming language in accordance with what is desired, we must understand the basic structure of the appropriate programming language to use. The more choices a programming language learns, the more structure it has to learn.

Each programming language has a basic structure of different programming languages, but the structure can be entered into several categories. Some of the basic structure categories of programming languages ​​that beginners can learn are:

  1. Structure of the Runtutan

It is the most basic algorithmic structure containing sequentially processed sequences of instructions, which are done one by one, from the first instruction until the last instruction means starting from step one, then second, third, and so on until the end. Basically a program does run a process from such a basic structure like this.

Each instruction in the run is written in a row, or several instructions in the same row but between each instruction separated by a semicolon (;).

  1. Repetition Structure

Sometimes, when running a program, we have to run a command over and over again, so that the program can run continuously. This structure can be the right choice to make a program run the command line repeatedly.
By using the basic structure of this programming language, a programmer can set the commands in the program to run repeatedly until in a condition where the requirement for iteration is not met again.
There are several looping functions that can be used to create the structure of this program, such as For, While, and While-do in C ++. These three functions can be used to create a program to run command lines in certain conditions.
For example, here's an example of programming using the For looping function in C ++:

for (int i = 0; i & lt; = 255; i ++)
{printf ("% d", i); }

In the above example, as long as the condition i <= 255 is met, the value i does not exceed 255, then the printf command ("% d", i) will be run by the program. And what if it is not fulfilled then the program will stop to run the command.

  1. Branching Structure

Creating a program also will not be separated from making an option in running the command in accordance with certain conditions. Program creators can use this structure to create a program with multiple decision options tailored to the terms or conditions desired.

For example, when we are going to create a device with several buttons that can be used to light a particular lamp according to the selected button using one of the many boards on the market, we can use this branching structure.
In the above conditions, we can use the If-Else or Switch Case function in the C programming language for the Arduino board. The following example is an example of a branching structure using the If-Else function for the mentioned case

if (digitalRead (key1) == 1)

{

digitalWrite (lamp1, HIGH);

digitalWrite (lamp2, LOW);

}

else if (digitalRead (button2) == 1)

{

digitalWrite (lamp1, LOW);

digitalWrite (lamp2, HIGH);

}

else

{

digitalWrite (lamp1, LOW);

digitalWrite (lamp2, LOW);

}

With the lines of code above then lamp 1 will light when button 1 is pressed, in code is digitalRead (button1) == 1, and lamp 2 will die. And vice versa, if button 2 is pressed, then lamp 1 will off and light 2 will light. However, if both buttons are not pressed, then both lights will be off.
Creating a program is an activity choosing which structure is right for the program. So a programmer must know the various types of basic structure of programming language, as described above.

After knowing the various structures and functions that can be used, program makers can choose and determine which structure is right for the program to be created. With the right structure then the program will be made in accordance with the desired.

Coin Marketplace

STEEM 0.27
TRX 0.13
JST 0.032
BTC 61562.85
ETH 2891.34
USDT 1.00
SBD 3.43