Will You Cope with Learning Computer Programming?
Try reading the following extract from this course. If this is challenging but not totally confusing to you; this course could be an ideal place to begin learning programming.
The following are the most important categories of code (or operators).
- Arithmetic operators,
- Assignment operators,
- Unary operators;
- Conditional operators,
- Comparison operators,
- String operators,
- Logical operators.
In general, the arithmetic operators are used as follows:
x + y;
x – y;
x * y;
x / y;
x % y.
Note that the % operator is the modulus operator (commonly known as the “mod operator”). It is used to divide the left hand operand by the right hand operand and returns the remainder of the division.
The most basic assignment operator is the “=” (equal) operator. It is used in most programming languages to assign a value to a variable. That’s why it is known as an “assignment operator”. For example, if you want to assign the value 25 to the variable “age”, you can do this simply by using the assignment operator, as follows: age = 25.
There are other assignment operators available, such as the +=, -=, *=, /= and %=. These operators combine arithmetic operators with the assignment operator to form operators in a compact form. These combined operators are used to perform an arithmetic operation on the value before it gets assigned to the variable.
For example, if you want to add the value 50 to the variable “age” and store the result in “age”, you can do this as follows: age = age + 25. This operation is also possible while using the combined += assignment operator available, as follows: age += 25.
So in general, a = a + b can be replaced by a += b.
We can apply the same logic to the other operators, as follows:
x = x + y is equivalent to x += y;
x = x - y is equivalent to x -= y;
x = x * y is equivalent to x *= y;
x = x / y is equivalent to x /= y;
x = x % y is equivalent to x %= y.
HOW TO LEARN MORE
Read a book, do a course, join an organisation; talk to people who know about computers.
Contact us -Talk to an Academic Officer
We provide a FREE COURSE AND CAREER COUNSELLING SERVICE
Learn from our experience.