create account

Introduction to Computer Programming - part 3 by humate

View this thread on: hive.blogpeakd.comecency.com
· @humate ·
$1.71
Introduction to Computer Programming - part 3
![enter image description here](https://s19.postimg.org/mlec5pm9f/ilya-pavlov-87438.jpg)


----------


----------


# 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)

----------

![enter image description here](https://s19.postimg.org/ov8fgg203/glenn-carstens-peters-203007_l.jpg)


----------


----------


### 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) 




![enter image description here](https://s19.postimg.org/vygaw2ukz/william-bout-264826_l.jpg)


----------

**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.

![enter image description here](https://s19.postimg.org/babohcfeb/rafael-pol-474017a.jpg)

----------
👍  , , , , , , , , , , , , , , , , , , , , , , , , , ,
properties (23)
authorhumate
permlinkintroduction-to-computer-programming-part-3
categoryeducation
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"}
created2018-01-05 07:28:09
last_update2018-01-05 07:28:09
depth0
children3
last_payout2018-01-12 07:28:09
cashout_time1969-12-31 23:59:59
total_payout_value1.495 HBD
curator_payout_value0.211 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length5,760
author_reputation107,931,380,458
root_title"Introduction to Computer Programming - part 3"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id27,218,808
net_rshares173,261,065,115
author_curate_reward""
vote details (27)
@drotto ·
<p>This post has received a 0.03 % upvote from @drotto thanks to: @banjo.</p>
👍  
properties (23)
authordrotto
permlinkre-humate-introduction-to-computer-programming-part-3-20180105t083144310z
categoryeducation
json_metadata{"tags":["education"],"app":"drotto/0.0.3rc3"}
created2018-01-05 08:31:45
last_update2018-01-05 08:31:45
depth1
children0
last_payout2018-01-12 08:31:45
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length78
author_reputation419,916,705,599
root_title"Introduction to Computer Programming - part 3"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id27,229,126
net_rshares427,507,914
author_curate_reward""
vote details (1)
@minnowsupport ·
<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=&amp;delegatee=minnowsupport&amp;vesting_shares=102530.639667%20VESTS">50SP</a>, <a href="https://v2.steemconnect.com/sign/delegateVestingShares?delegator=&amp;delegatee=minnowsupport&amp;vesting_shares=205303.639667%20VESTS">100SP</a>, <a href="https://v2.steemconnect.com/sign/delegateVestingShares?delegator=&amp;delegatee=minnowsupport&amp;vesting_shares=514303.639667%20VESTS">250SP</a>, <a href="https://v2.steemconnect.com/sign/delegateVestingShares?delegator=&amp;delegatee=minnowsupport&amp;vesting_shares=1025303.639667%20VESTS">500SP</a>, <a href="https://v2.steemconnect.com/sign/delegateVestingShares?delegator=&amp;delegatee=minnowsupport&amp;vesting_shares=2053030.639667%20VESTS">1000SP</a>, <a href="https://v2.steemconnect.com/sign/delegateVestingShares?delegator=&amp;delegatee=minnowsupport&amp;vesting_shares=10253030.639667%20VESTS">5000SP</a>.  <strong>Be sure to leave at least 50SP undelegated on your account.</strong></p>
👍  
properties (23)
authorminnowsupport
permlinkre-humate-introduction-to-computer-programming-part-3-20180105t081952264z
categoryeducation
json_metadata{"tags":["education"],"app":"cosgrove/0.0.2"}
created2018-01-05 08:19:51
last_update2018-01-05 08:19:51
depth1
children0
last_payout2018-01-12 08:19:51
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length1,744
author_reputation148,902,805,319,183
root_title"Introduction to Computer Programming - part 3"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id27,227,096
net_rshares434,403,203
author_curate_reward""
vote details (1)
@steemitboard ·
Congratulations @humate! You have completed some achievement on Steemit and have been rewarded with new badge(s) :

[![](https://steemitimages.com/70x80/http://steemitboard.com/notifications/votes.png)](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)!
properties (22)
authorsteemitboard
permlinksteemitboard-notify-humate-20180109t193902000z
categoryeducation
json_metadata{"image":["https://steemitboard.com/img/notifications.png"]}
created2018-01-09 19:39:00
last_update2018-01-09 19:39:00
depth1
children0
last_payout2018-01-16 19:39:00
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length682
author_reputation38,975,615,169,260
root_title"Introduction to Computer Programming - part 3"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id28,324,350
net_rshares0