- Back to Home »
- Decision Making, Looping, Array, & Function
Posted by : Unknown
Rabu, 21 September 2016
Decision Making, Looping, Array, & Function
Hi Guys, in this post we will learn about "Decision making, looping, array, & function", so first of all, let's explain what is it .
Decision making
Decision making , just like the name, it's about making a decision of what order we will make to our program. For example execution of statements based on certain conditions or repeat it until certain specified conditions are met.
Looping
Just like the name, looping is an instruction to do something over and over until the determined limit.
Array
Array is a group of variabel that has the same data type, it is usefull for saving data and object reference in large number
Function
Function is a part of program that use to do spesific task.
So, we already learn about what is the definition of these guy. Next we'll learn about how to use it in our program ^^
Decision Making
There are 3 type of Decision making
- if
- if-else
- switch
If
If use to program to execute a certain part of code only if particular condition is true
Example :
and the result is ....
Else if
Just like if, else if is use to execute one block of statement among two blocks.
Switch
Switch statement work with byte, short, char, and int primitive data type
for example :
and the result ..
Looping
Looping is an intruction to make program do something several times, it is very usefull if u need to do something over and over.
there are 3 kind of looping
- While
- Do while
- for
While
While will check the instruction first then do the loop, if there's no correct condition, it will end nothing
Do While
Do while, different from while, it will do the looping first
For
It allows you to controll and write specific loop that need to execute
Here's a example of looping
the result ..
Array
Because we already know what is array at the beginning of the post, i ll give you example of Array
and the result ...
Function
Just like what we learn at the beginning, function is a program that do specific task, we can call it sub-program , for the example is "int main" and all programs that can define additional functions.
Alright that's my post today ^^, hope you enjoy it.
Bye byeee