First, a few definitions:

•  A statement is a unit of code that does something –a basic building block of a program.

• An expression is a statement that has a value – for instance, a number, a string, the sum of two numbers, etc. 4+2, x-1, and "Hello, world!\n" are all expressions.
Not every statement is an expression. It makes no sense to talk about the value of an #include statement, for instance.



Operators


We can perform arithmetic calculations with operators. Operators act on expressions toform a new expression. For example, we could replace "Hello, world!\n" with (4 + 2) / 3, which would cause the program to print the number 2. In this case, the + operator acts on the expressions 4 and 2 (its operands).

Operator types:


• Mathematical: +, -, *, /, and parentheses have their usual mathematical meanings, including using -for negation. % (the modulus operator) takes the remainder of two numbers: 6%5 evaluates to 1.

•Logical: used for “and,” “or,” and so on. More on those in the next lecture.

•Bitwise: used to manipulate the binary representations of numbers. We will not focus on these.
Designed By Blogger Templates | Templatelib & Distributed By Blogspot Templates