Operators: Difference between revisions

From Computer Science Wiki
No edit summary
No edit summary
Line 10: Line 10:
[[file:arrows.png|right|frame|Programming basics<ref>http://www.flaticon.com/</ref>]]
[[file:arrows.png|right|frame|Programming basics<ref>http://www.flaticon.com/</ref>]]


An operator is something that takes one or more values (or expressions, in programming jargon) and yields another value (so that the construction itself becomes an expression).
An operator is something that takes one or more values (or expressions, in programming jargon) and yields another value (so that the construction itself becomes an expression)<ref>http://php.net/manual/en/language.operators.php</ref>


There are many different types of operators, but the ones we primarily concern ourselves with are boldfaced below:
There are many different types of operators, but the ones we primarily concern ourselves with are boldfaced below:

Revision as of 17:46, 19 September 2016

Exclamation.png Warning!!!!

Operators are very important. The way the IB wants you to use operators is different than the way you will use them in real life.


Programming basics[1]

An operator is something that takes one or more values (or expressions, in programming jargon) and yields another value (so that the construction itself becomes an expression)[2]

There are many different types of operators, but the ones we primarily concern ourselves with are boldfaced below:

  • Operator Precedence
  • Arithmetic Operators
  • Assignment Operators
  • Bitwise Operators
  • Comparison Operators
  • Error Control Operators
  • Execution Operators
  • Incrementing/Decrementing Operators
  • Logical Operators
  • String Operators
  • Array Operators
  • Type Operators


An example of a simple array in PHP can be found below:

<?php
# this file  is used to teach the VERY BASICS of arrays in PHP

$pizza_toppings = array (
"extra cheese"
"onions"
"pepperoni"
"ham"
"pineapple"
"chicken"
"arugula"
"pesto"
);

# This creates a very simple array with 8 items. 

?>

A video[edit]

This video references the C programming language and scratch, but the ideas about operators are excellent. In the case of conditionals, PHP and C share similar syntax (but not exact).

The way the IB wants you to use operators[edit]

Please know all code submitted to the IB (with the exception of object oriented programming) is in pseudocode. The way we write operators in pseudocode is different than the way we might write them in the real world.

Click here to view a file describing approved notation, including pseudocode This is the approved notation sheet from the IB.

Below is a graphic that is taken from the above PDF file to help you understand how the IB wants operators to look.

Ib operators.png

Standards[edit]

  • Define the terms: variable, constant, operator, object.
  • Define common operators.
  • Analyse the use of variables, constants and operators in algorithms.

See Also[edit]

References[edit]