Programming basic syntax of Making Decision and Looping


         Hello Programmer! Today I want explain and show to you about some syntax in C programming language. Let’s start and Enjoy! 


Making Decision

         How to use making decision on programming? Making Decision used when you want to execute a syntax or select some statements to be executed base on outcome of condition (whether is true or false).
In Making Decision on C there are:
Ø If statement (if)
Ø If else statement (if else)
Ø Nested if else statement (if elseif else)
Ø Switch case construct
        Let me give you an example, this is the syntax when you want to make a if statement,if else statement, if elseif else statement and switch case.

  Ø If statement: is used when you want to execute one condition is true
Example:
(Input)

When you run the if statement will show this output:
(Output)


  Ø If else statement: is used when you want to executes if condition is true and the other if is false.


Example:

(Input)


When you run it the if else statement will show this output:

(Output)


  Ø Nested if else statement (if elseif else): is used when you want to executes codes, if for two more condition.

Example:
(Input)



When you run it the if elseif else statement will show this output:
(Output)

  Ø Switch Case : is used to selects one of many blocks of code to be executed.
Example:
(Input)


When you run it the switch case will show this output:
(Output)


     Loop

        Loop is used when loop is used to repeat a process code. the purpose of the lob is to facilitate programmer to not use too much syntax. There are 3 type in loop:
  Ø While
  Ø Do While
  Ø For

Ø“While” loop: is used when you want to looping when the code amount is not known."While" usually used in structured code,  when the code is true, the code will increase up to its maximum limit and stop adding value.

Example:
(Input)


When you run it the “while” loop will show this output:

(Output)


Ø“Do While” Loop: is used when you want do while used to test a statement then tested whether the value is correct or not. "Do while" will test the code it will increase to the limit and if not properly true codes it still be tested.
Example :
(Input)


This is the output when you run the “do while” the output is going to be like this:



Ø“For” Loop: is used when you want to implement the looping statements to predetermined value.
Example:
(Input)



When you run the “for” loop it will show this output:
(Output)


Okay guys that’s enough for this post maybe I will post the function and array syntax later… keep practicing guys try an online judge or practice it by yourself, see you later guys! ^^ 

Comments

Popular posts from this blog