Introduction to Computer Programming - part 4

View this thread on: d.buzz | hive.blog | peakd.com | ecency.com
ยท@humateยท
0.000 HBD
Introduction to Computer Programming - part 4
![enter image description here](https://steemit-production-imageproxy-thumbnail.s3.amazonaws.com/U5drcG3vrppf3JtWrsGUfp8VkX29tCq_1680x8400)


----------


----------


## INTRODUCTION TO PROGRAMMING

I am collating my study notes as part of my education into Computer Programming. In an attempt to increase and improve my own learning, and to help others also (learn by teaching) I will be sharing my notes, as neatly presented as possible, for others to follow along with if they so wish. This is Lesson 4's notes.


----------


EARLIER LESSONS

[Lesson 1 Notes](https://steemit.com/education/@humate/introduction-to-computer-programming)
[Lesson 2 Notes](https://steemit.com/education/@humate/introduction-to-computer-programming-part-2)
[Lesson 3 Notes](https://steemit.com/education/@humate/introduction-to-computer-programming-part-3)


----------
![enter image description here](https://steemit-production-imageproxy-thumbnail.s3.amazonaws.com/U5drtM9Qos9WMkJj6w1DoVNDSLa3C2C_1680x8400)

----------

### INTRODUCTION TO COMPUTER PROGRAMMING โ€“ STUDY NOTES
**LESSON 4**


----------


**CONTROL FLOW**

Control Flow = creating an order in which statements will be executed in a program.

Conditional Statements = tells the program to do a certain action if a condition is met.
The below are examples of conditional statements.


----------


**IF STATEMENT**

    if(true)
    {
    do this
    }

If the statement is [true] then execute the code [do this]


----------


Example of C++ code utilising the *if* statement.

![enter image description here](https://image.ibb.co/bRVGzG/if_statement.jpg")


----------


**IF ELSE STATEMENT**

    if(true)
    {
    do this
    } 
    else 
    {
    do this instead
    }

If statement is [true] then execute the code [do this].
Otherwise execute the second code [do this instead]

Defensive programming = offer the else statement to allow for possible issues.
LINK: [Defensive Programming](https://en.wikipedia.org/wiki/Defensive_programming)


----------


Example of C++ code utilising the *if...else* statement.

![enter image description here](https://image.ibb.co/hs7JDb/if_then_statement.jpg)

----------


**IF THEN STATEMENT**

    if(true)
    {
    do this
    }
    else if(true)
    {
    do this instead
    }
    else
    {
    just do this
    }

If statement is [true] then execute the code [do this].

If it's not true then check another statement [else] and see if that one is [true]. If it is then execute it's code [do this instead].

There can be more of them to follow. In the above example it is just two.
If neither of them is true, then execute the last code [just do this].


----------


Example of C++ code utilising the *if...then* statement.

![enter image description here](https://image.ibb.co/kwX76w/If_then_statement_2.jpg)

Second example of C++ code utilising the *if...then* statement.

![enter image description here](https://image.ibb.co/iQU9KG/if_then_statement_3.jpg)

----------

**RECAP OF LESSON 1, 2 AND 3**

In **Lesson 1** we briefly looked at:

- What is a programming language?
- Language Types โ€“ especially HIGH Level and LOW Level.
- Compiled vs Interpreted Languages
- Data Types: Strongly Typed vs Weakly Typed Languages.
- Data Types: The most common data types (characters, integers, floating-point, fixed-point, boolean, reference).

In **Lesson 2** we looked briefly looked at:

- Variables
- Constants

These both flow on from Data Types and work with these.

In **Lesson 3** we looked briefly at:

- Operators

Used to allow operations (such as multiplication) to be performed on variables or constants.

----------

![enter image description here](https://steemit-production-imageproxy-thumbnail.s3.amazonaws.com/U5dsT9d5jbweoK8z1LMpCpf62x6uPhp_1680x8400)

----------

**FURTHER DATA**

[cpp.sh](cpp.sh) - C++ shell website
Scratchpad - Shift + F4 on Firefox - Javascript shell
[Dev C++](https://sourceforge.net/projects/orwelldevcpp/) - A free, portable, fast and simple C/C++ IDE
[Code::Blocks](http://www.codeblocks.org/) - A free C, C++ and Fortran IDE
[Ideone](https://ideone.com/) - an online compiler and debugging tool which allows youto compile source code and execute it online in more than 60 programming languages.


----------

My Posts

[Introduction From a Newbie Programmer](https://steemit.com/introduceyourself/@humate/introduction-from-a-newbie-programmer) and [Intro - part 2](https://steemit.com/introduceyourself/@humate/my-introduction-part-2)
[Introduction to Computer Programming - part 1](https://steemit.com/education/@humate/introduction-to-computer-programming) (Lesson 1)
[Introduction to Computer Programming - part 2](https://steemit.com/education/@humate/introduction-to-computer-programming-part-2) (Lesson 2)
[Introduction to Computer Programming - part 3](https://steemit.com/education/@humate/introduction-to-computer-programming-part-3) (Lesson 3)


----------


Images from unsplash.com.

I welcome new [followers](https://steemit.com/@humate), and thank you for your upvotes and comments.

![enter image description here](https://steemit-production-imageproxy-thumbnail.s3.amazonaws.com/U5dquXPi98PpoLFfPH1PWfms98r4u97_1680x8400)
๐Ÿ‘ , , , , , , , , , , , , , , , , , , , , , , , , , , ,