Programming Logic : Basic Operators
Hello Reader,
I believe you are getting stronger and stronger each day as a programmer and I am happy for you !
Today , I am going to talk about Operators , they are a big part of learning Programming Logic as we shall see as the article unfolds.
Operators help us create more functional code.....It is a cornerstone to Programming Logic.
Let us start Operating...BOIII ! :
What are operators ?
Operators are symbols that tell the compiler to perform specific mathematical or logical manipulations.
Today , we will try to cover the most commonly used operators in programming.
First, let's categorize them:
1. Arithmetic
2. Relational
3. Bitwise
4. Logical
5. Assignment
6. Increment
7. Miscellaneous
1. Arithmetic Operators:
+ Addition
* Multiplication
% Modulus
The modulus operator - or more precisely, the modulo operation - is a way to determine the remainder of a division operation. Instead of returning the result of the division, the modulo operation returns the whole number remainder.
/ Division
- Subtraction
Example :
Addition:
a+b=c
lets say a = 3
b=5
5+3=8
so c=8
Multiplication:
e*f=d
e=3
f=7
7*3=21
d=21
Modulus:
y%z=x
y=6
z=14
now, 6 can go into 14 , 2 times(12) but a remainder remains which is 2
x=2
The modulus operator simply gives us the remainder result of the operation.
Division:
r/p=n
r=20
p=10
n=2
Subtraction:
v-l=h
v=20
l=12
h=8
Simple Cheat Sheet on Arithmetic Operators :
These operators are used for comparison.
They return either true or false based on the comparison result. The operator '==' should not be confused with '='.
These operators convert the given integers into binary and then perform the required operation, and give back the result in decimal representation.
4. Logical Operators
These operators take boolean values as input and return boolean values as output.
These operators are used to assign values to variables.
These operators affect the variable value by 1 , useful when making small adjustments
I know pretty much of what I have shared has been confusing but it will make sense the more you practice it.
Everything here will become a part of you with practice !
Think of this article as an eye opener then let yourself go loose looking for in depth application of operations and most of applying them in your code practice to get better at coding.
Good Day !
Comments
Post a Comment
Share your thoughts