 ---------- ---------- # INTRODUCTION TO PROGRAMMING I am collating my study notes as part of my education into Computer Programming. In an attempt to increase and improce 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 3'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) ----------  ---------- ---------- ### INTRODUCTION TO COMPUTER PROGRAMMING – STUDY NOTES **LESSON 3** ---------- **OPERATORS** LINK: [Operators](https://en.wikipedia.org/wiki/Operator_(computer_programming)) Operators allow you to operate on an element of the program. - **Assignment** > `=` > This means to apply the value of. For example x = y means to apply the value of x to y. It is not the same meaning as standard mathematics where it means equal to. - **Arithmetic Operators** > `+`Addition > `-`Subtraction > `*`Multiplication > `/`Division > `%`Modulo - Modulo = remainder of a division operation. >Example 143 / 3 = 47.66 (standard division) but if you take only the whole numbers, then the modulo of that operation is 143 / 3 = 47, WITH a remainder of 2. In other words, 47 * 3 = 141 and the difference between 143 and 141 is 2 (This is the modulo, or the remainder). There is a need for such an operator within programming languages. - **Compound Operators** > `+=` : x+=y is the same as saying x=x+y > `-+` : x-=y is the same as saying x=x-y > `*+` : x*=y is the same as saying x=x*y > `/=` : x/=y is the same as saying x=x/y > `%=` : x%=y is the same as saying x=x%y This allows for a slightly shorter way of writing out these operators. - **Unary Operators** > `++` : `X++` is the same as saying `x=x+1` (used a lot in loops) > `--` : `X--` is the same as saying `x=x-1` (used a lot in loops) > `!` : Means NOT. > Example : `x=true`, then `!x` would then be false (ie - NOT true) - **Prefix Operator vs Suffix Operator** LINK: [Increment and Decrement Operators](https://en.wikipedia.org/wiki/Increment_and_decrement_operators) When the ++ or -- is set as a prefix as opposed to a suffix like earlier described, then the value of the variable that it relates to is handled differently. The variable is increased FIRST then assigned to the new variable. > **Prefix** Example: > `x = 3` > `y = ++x` > In this example x is assigned (=) the value of 3, and then because of the PREFIX in the second line, x is increased by 1 to 4 (++x) BEFORE y is assigned that value. Now both x and y have the value of 4. The suffix example would create a different answer. > **Suffix** Example > `x = 3` > `y = x++` > In this example x is assigned (=) the value of 3, and then because of the SUFFIX in the second line, x is increased by 1 to 4 (x++) AFTER y is assigned that value. So y is assigned the value of x which is 3, THEN x is increased by 1 to 4. This seemingly minor but significant difference can lead to logical errors in your program if you apply the wrong use of suffix/prefix. Suffix = value is assigned first before it is increased. Prefix = value is increased first before it is assigned. - **Relational/Comparison Operator** Used to compare 2 values. Will always evaluate to a Boolean value (TRUE or FALSE). > `==` : equal to > `!=` : not equal to > `>` : greater than > `<` : less than > `>=` : greater than or equal to > `<=` : less than or equal to **- Logical Operator** Used to tell the computer to do an operation when certain conditions or mix of conditions are met. Such as condition 1 AND condition 2; condition 1 OR condition 2. Also the NOT operator. > `!` : NOT : > `&&` : AND : True only when both conditions are true. > `||` : OR : True if one or the other is true. - **Operator Precedence** There is an order to which operators are evaluated. There is an order of importance. All the languages use the same precedence. ---------- LINK: [C++ Example](http://www.cplusplus.com/doc/tutorial/operators/) LINK: [JavaScript Example](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Expressions_and_Operators)  ---------- **FURTHER DATA** [cpp.sh](http://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). [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) ---------- Images from [unsplash.com](https://unsplash.com/). I welcome new followers, and thank you for your upvotes and comments.  ----------
author | humate |
---|---|
permlink | introduction-to-computer-programming-part-3 |
category | education |
json_metadata | {"tags":["education","howto","steemiteducation","technology","teamaustralia"],"image":["https://s19.postimg.org/mlec5pm9f/ilya-pavlov-87438.jpg","https://s19.postimg.org/ov8fgg203/glenn-carstens-peters-203007_l.jpg","https://s19.postimg.org/vygaw2ukz/william-bout-264826_l.jpg","https://s19.postimg.org/babohcfeb/rafael-pol-474017a.jpg"],"links":["https://steemit.com/education/@humate/introduction-to-computer-programming","https://steemit.com/education/@humate/introduction-to-computer-programming-part-2","https://en.wikipedia.org/wiki/Operator_(computer_programming)","https://en.wikipedia.org/wiki/Increment_and_decrement_operators","http://www.cplusplus.com/doc/tutorial/operators/","https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Expressions_and_Operators","http://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://unsplash.com/"],"app":"steemit/0.1","format":"markdown"} |
created | 2018-01-05 07:28:09 |
last_update | 2018-01-05 07:28:09 |
depth | 0 |
children | 3 |
last_payout | 2018-01-12 07:28:09 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 1.495 HBD |
curator_payout_value | 0.211 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 5,760 |
author_reputation | 107,931,380,458 |
root_title | "Introduction to Computer Programming - part 3" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 27,218,808 |
net_rshares | 173,261,065,115 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
pharesim | 0 | 94,512,993,421 | 0.02% | ||
bue | 0 | 13,815,905,034 | 100% | ||
christoryan | 0 | 453,422,374 | 1% | ||
edrivegom | 0 | 124,562,678 | 0.1% | ||
gomeravibz | 0 | 2,007,767,475 | 0.6% | ||
stephen.king989 | 0 | 1,046,485,476 | 0.2% | ||
naquoya | 0 | 35,749,747,174 | 100% | ||
jhermanbeans | 0 | 341,189,042 | 0.1% | ||
steemprentice | 0 | 1,149,458,000 | 0.1% | ||
naq1 | 0 | 777,581,455 | 100% | ||
pomperipossa | 0 | 319,273,495 | 0.1% | ||
humate | 0 | 445,895,352 | 100% | ||
banjo | 0 | 231,286,111 | 1% | ||
numpypython | 0 | 159,752,212 | 0.1% | ||
looftee | 0 | 296,050,772 | 0.1% | ||
dickturpin | 0 | 166,506,981 | 1% | ||
decibel | 0 | 139,840,912 | 0.5% | ||
gindor | 0 | 283,598,068 | 0.2% | ||
qwasert | 0 | 117,137,437 | 0.2% | ||
cryptohustler | 0 | 186,137,893 | 1% | ||
minnowsupport | 0 | 17,834,716,322 | 1% | ||
crypto-learnings | 0 | 249,017,489 | 100% | ||
myday | 0 | 168,078,546 | 0.1% | ||
gamerveda | 0 | 708,932,197 | 0.5% | ||
nesbitt | 0 | 60,859,193 | 1% | ||
drotto | 0 | 1,629,568,937 | 0.03% | ||
raci | 0 | 285,301,069 | 0.7% |
<p>This post has received a 0.03 % upvote from @drotto thanks to: @banjo.</p>
author | drotto |
---|---|
permlink | re-humate-introduction-to-computer-programming-part-3-20180105t083144310z |
category | education |
json_metadata | {"tags":["education"],"app":"drotto/0.0.3rc3"} |
created | 2018-01-05 08:31:45 |
last_update | 2018-01-05 08:31:45 |
depth | 1 |
children | 0 |
last_payout | 2018-01-12 08:31:45 |
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 | 78 |
author_reputation | 419,916,705,599 |
root_title | "Introduction to Computer Programming - part 3" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 27,229,126 |
net_rshares | 427,507,914 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
humate | 0 | 427,507,914 | 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/crimsonclad, and netuoso. The goal is to help Steemit grow by supporting Minnows and creating a social network. Please find us in 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>. <strong>Be sure to leave at least 50SP undelegated on your account.</strong></p>
author | minnowsupport |
---|---|
permlink | re-humate-introduction-to-computer-programming-part-3-20180105t081952264z |
category | education |
json_metadata | {"tags":["education"],"app":"cosgrove/0.0.2"} |
created | 2018-01-05 08:19:51 |
last_update | 2018-01-05 08:19:51 |
depth | 1 |
children | 0 |
last_payout | 2018-01-12 08:19:51 |
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,744 |
author_reputation | 148,902,805,319,183 |
root_title | "Introduction to Computer Programming - part 3" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 27,227,096 |
net_rshares | 434,403,203 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
humate | 0 | 434,403,203 | 100% |
Congratulations @humate! You have completed some achievement on Steemit and have been rewarded with new badge(s) : [](http://steemitboard.com/@humate) Award for the number of upvotes Click on any badge to view your own Board of Honor on SteemitBoard. For more information about SteemitBoard, click [here](https://steemit.com/@steemitboard) If you no longer want to receive notifications, reply to this comment with the word `STOP` > 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-20180109t193902000z |
category | education |
json_metadata | {"image":["https://steemitboard.com/img/notifications.png"]} |
created | 2018-01-09 19:39:00 |
last_update | 2018-01-09 19:39:00 |
depth | 1 |
children | 0 |
last_payout | 2018-01-16 19:39:00 |
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 | 682 |
author_reputation | 38,975,615,169,260 |
root_title | "Introduction to Computer Programming - part 3" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 28,324,350 |
net_rshares | 0 |