 ---------- ---------- ## 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 5'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) [Lesson 4 Notes](https://steemit.com/education/@humate/introduction-to-computer-programming-part-4) ----------  ---------- ### INTRODUCTION TO COMPUTER PROGRAMMING – STUDY NOTES **LESSON 5** ---------- **CONTROL FLOW** Control Flow = creating an order in which statements will be executed in a program. We touched briefly on **Control Flow** in lesson 4 where we discussed **Conditional Statements**. In this lesson we are looking at **Loops**. Loops = a loop has a condition, and so long as that condition is true, the code will continue to run. When it become false then the code will end. LINK: [Control Flow](https://en.wikipedia.org/wiki/Control_flow) ---------- **While Loop** initialise while (true){ do this increment/decrement } more code  The above example prints out a line (I will be good in class) 50 times. The code checks that `X` is less than or equal to 50, and so long as that is true then the statement gets printed. When the code becomes false `(x > 50)` then the code will exit the loop. ---------- **Do-while Loop** initialise do { do this increment/decrement } while (true) more code The difference between the *Do-While Loop* and the *While Loop* is that the *Do-While Loop* will be executed at least once, whereas the *While-Loop* contains the possibility that the code wont get run at all.  The example is similar code to the above, but has been written as a *Do-While Loop*, and had `X` changed to 100. This makes the *While* statement false. This example is to illustrate that the code still prints out once (see line at bottom of screenshot that says '100: I will be good in class'.) ---------- **For Loop** for (initialisation; condition; increment/decrement){ statement; } more code The *For Loop* puts everything into the brackets and determines if it's true before running the statement.  ---------- **Jump Statements** **Break** = used to immediately jump out of a loop block.  The above example runs the loop, and then forces the loop to stop when `X==10`. At that point it is now outside the loop code. **Continue** = skips the rest of a loop and jumps back to the top of the loop.  In the above example the *If Statement* is true if the number is odd. `(X%2 == 1)` is true if the number is odd, and this causes the *Continue Statement* to run, causing the odd number not to print (instead the loop continues back to the top), and the loop starts again from the last (non-printed) number. In other words, this loop will print the even numbers, and skip the odd numbers. ---------- **RECAP OF EARLIER LESSONS** 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. In **Lesson 4** we looked briefly at: - Conditional Statements *If*, *If-Else*, *If-Then* Statements, which are used to control the flow of a program. ----------  ---------- **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) [Introduction to Computer Programming - part 4](https://steemit.com/education/@humate/introduction-to-computer-programming-part-4) (Lesson 4) ---------- Images from unsplash.com, except code screenshots, which are my own. I welcome new [followers](https://steemit.com/@humate), and thank you for your upvotes and comments.
author | humate |
---|---|
permlink | introduction-to-computer-programming-part-5 |
category | education |
json_metadata | {"tags":["education","howto","steemiteducation","technology","teamaustralia"],"image":["https://steemit-production-imageproxy-thumbnail.s3.amazonaws.com/U5drcG3vrppf3JtWrsGUfp8VkX29tCq_1680x8400","https://steemit-production-imageproxy-thumbnail.s3.amazonaws.com/U5drtM9Qos9WMkJj6w1DoVNDSLa3C2C_1680x8400","https://s19.postimg.org/alf68sy4j/While_1.jpg","https://s19.postimg.org/v5k07a65v/Do-_While_1.jpg","https://s19.postimg.org/xzn5kq0mb/For_1.jpg","https://s19.postimg.org/9vwdwf2pv/Break_1.jpg","https://s19.postimg.org/8tm7dvrmb/Continue_1.jpg","https://steemit-production-imageproxy-thumbnail.s3.amazonaws.com/U5dsT9d5jbweoK8z1LMpCpf62x6uPhp_1680x8400"],"links":["https://steemit.com/education/@humate/introduction-to-computer-programming","https://steemit.com/education/@humate/introduction-to-computer-programming-part-2","https://steemit.com/education/@humate/introduction-to-computer-programming-part-3","https://steemit.com/education/@humate/introduction-to-computer-programming-part-4","https://en.wikipedia.org/wiki/Control_flow","cpp.sh","https://sourceforge.net/projects/orwelldevcpp/","http://www.codeblocks.org/","https://ideone.com/","https://steemit.com/introduceyourself/@humate/introduction-from-a-newbie-programmer","https://steemit.com/introduceyourself/@humate/my-introduction-part-2","https://steemit.com/@humate"],"app":"steemit/0.1","format":"markdown"} |
created | 2018-01-27 02:40:03 |
last_update | 2018-01-27 02:40:03 |
depth | 0 |
children | 4 |
last_payout | 2018-02-03 02:40:03 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 1.286 HBD |
curator_payout_value | 0.212 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 6,389 |
author_reputation | 107,931,380,458 |
root_title | "Introduction to Computer Programming - part 5" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 32,624,427 |
net_rshares | 171,767,353,618 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
spiry-btc | 0 | 411,510,805 | 25% | ||
ausbitbank | 0 | 83,245,198,483 | 1% | ||
naquoya | 0 | 22,818,436,898 | 100% | ||
technology-trail | 0 | 2,303,854,183 | 100% | ||
remlaps2 | 0 | 1,843,282,058 | 100% | ||
naq1 | 0 | 777,581,455 | 100% | ||
humate | 0 | 489,428,725 | 100% | ||
cub2 | 0 | 50,147,905 | 100% | ||
minnowsupport | 0 | 18,813,687,758 | 0.5% | ||
crypto-learnings | 0 | 249,017,489 | 100% | ||
teamaustralia | 0 | 3,443,362,438 | 9% | ||
centerlink | 0 | 36,716,441,872 | 10% | ||
zinzilon | 0 | 605,403,549 | 100% |
<p>Congratulations! This post has been upvoted from the communal account, @minnowsupport, by humate from the Minnow Support Project. It's a witness project run by aggroed, ausbitbank, teamsteem, theprophet0, someguy123, neoxian, followbtcnews, and netuoso. The goal is to help Steemit grow by supporting Minnows. Please find us at the <a href="https://discord.gg/HYj4yvw"> Peace, Abundance, and Liberty Network (PALnet) Discord Channel</a>. It's a completely public and open space to all members of the Steemit community who voluntarily choose to be there.</p> <p>If you would like to delegate to the Minnow Support Project you can do so by clicking on the following links: <a href="https://v2.steemconnect.com/sign/delegateVestingShares?delegator=&delegatee=minnowsupport&vesting_shares=102530.639667%20VESTS">50SP</a>, <a href="https://v2.steemconnect.com/sign/delegateVestingShares?delegator=&delegatee=minnowsupport&vesting_shares=205303.639667%20VESTS">100SP</a>, <a href="https://v2.steemconnect.com/sign/delegateVestingShares?delegator=&delegatee=minnowsupport&vesting_shares=514303.639667%20VESTS">250SP</a>, <a href="https://v2.steemconnect.com/sign/delegateVestingShares?delegator=&delegatee=minnowsupport&vesting_shares=1025303.639667%20VESTS">500SP</a>, <a href="https://v2.steemconnect.com/sign/delegateVestingShares?delegator=&delegatee=minnowsupport&vesting_shares=2053030.639667%20VESTS">1000SP</a>, <a href="https://v2.steemconnect.com/sign/delegateVestingShares?delegator=&delegatee=minnowsupport&vesting_shares=10253030.639667%20VESTS">5000SP</a>. <br><strong>Be sure to leave at least 50SP undelegated on your account.</strong></p>
author | minnowsupport |
---|---|
permlink | re-introduction-to-computer-programming-part-5-20180201t095057 |
category | education |
json_metadata | "" |
created | 2018-02-01 09:50:57 |
last_update | 2018-02-01 09:50:57 |
depth | 1 |
children | 0 |
last_payout | 2018-02-08 09:50:57 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 1,702 |
author_reputation | 148,902,805,319,183 |
root_title | "Introduction to Computer Programming - part 5" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 34,091,497 |
net_rshares | 756,347,704 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
humate | 0 | 756,347,704 | 100% |
Congratulations @humate! You have received a personal award! [](http://steemitboard.com/@humate) 1 Year on Steemit Click on the badge to view your own Board of Honor on SteemitBoard. > By upvoting this notification, you can help all Steemit users. Learn how [here](https://steemit.com/steemitboard/@steemitboard/http-i-cubeupload-com-7ciqeo-png)!
author | steemitboard |
---|---|
permlink | steemitboard-notify-humate-20180206t062817000z |
category | education |
json_metadata | {"image":["https://steemitboard.com/img/notifications.png"]} |
created | 2018-02-06 06:28:18 |
last_update | 2018-02-06 06:28:18 |
depth | 1 |
children | 0 |
last_payout | 2018-02-13 06:28:18 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 431 |
author_reputation | 38,975,615,169,260 |
root_title | "Introduction to Computer Programming - part 5" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 35,325,544 |
net_rshares | 0 |
hi i am studying programming as well, but i am a super newbie .... so can you please help me with writing functions please?
author | zinzilon |
---|---|
permlink | re-humate-introduction-to-computer-programming-part-5-20180127t024228375z |
category | education |
json_metadata | {"tags":["education"],"app":"steemit/0.1"} |
created | 2018-01-27 02:42:06 |
last_update | 2018-01-27 02:42:06 |
depth | 1 |
children | 1 |
last_payout | 2018-02-03 02:42:06 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 123 |
author_reputation | 114,314,996,146 |
root_title | "Introduction to Computer Programming - part 5" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 32,624,763 |
net_rshares | 482,087,294 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
humate | 0 | 482,087,294 | 100% |
We're both super-newbies. I am sharing my notes as I study them. Study along with me and maybe you will learn about functions soon. After this introduction course I will be sharing my notes on a C++ course. Functions are made up of the material I am sharing (Control Flow Statements etc), but the knowledge on how to write them efficiently needs to be learned. I am still learning that.
author | humate |
---|---|
permlink | re-zinzilon-re-humate-introduction-to-computer-programming-part-5-20180127t024549952z |
category | education |
json_metadata | {"tags":["education"],"app":"steemit/0.1"} |
created | 2018-01-27 02:45:54 |
last_update | 2018-01-27 02:45:54 |
depth | 2 |
children | 0 |
last_payout | 2018-02-03 02:45:54 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 387 |
author_reputation | 107,931,380,458 |
root_title | "Introduction to Computer Programming - part 5" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 32,625,370 |
net_rshares | 0 |