In this part of Algorithm and Programming subject, we were taught of Operations, Operands, and Arithmetic of Algorithm and Programming.
Operators are divided into few types, there are:
- Assignment Operator
- Logical Operator
- Arithmetic Operator
- Relational Operator
- Bitwise Operator
- Pointer Operator
Those Operators have their own functions, for example:
1. Assignment Operators
it is used to assign values to an operand.
Syntax : Operand1 = Operand2;
Or it basically says that Operand1 has the same value with Operand2.
2. Arithmetic Operators
it is used to implicate arithmetic and maths in programmings. All are according to which arithmetic system it implicates.
"+" for adding some value to an operand.
"-" for decreasing some value to an operand.
"*" for timing the value of an operand.
"/" for dividing the value of an operand.
"%" for gaining the modulo of an operand.
"++" for implying an increment to an operand.
"--" for implying a decrement to an operand.
"()" for giving a higher priority to some operation inside the scope.
3. Relational Operators
This is used for comparing values with TRUE or FALSE result. Relational Operations are divided into these types:
"==" for finding which an operand is equal to the other or not.
"!=" for finding the opposite result of what equality operation does.
"<" for finding if an operand is less than the other.
">" for finding if an operand is greater than the other.
"<=" for finding if an operand is less or equals to the other.
">=" for finding if an operand is greater or equals to the other.
"?:" for finding the result whether some certain condition is true or false.
4. Logical Operators
This operator is used for additional logical options for relational operations. It is divided to these types:
"&&" or basically it is "and"
"||" or basically it is "or"
"!" for "not"
The logics of these operators are according to truth table in Discrete Mathematics
5. Bitwise Operators
This kind of operators plays with the bitwise value of each operands. For example:
int A=24,B=35,C,D;
C = A & B; //value of C = 0
D = A | B; //value of D = 59
Notes:
A = 24, binary : 011000
B = 35, binary : 100011
Bit by bit AND operation resulting: 000000, in decimal: 0
Bit by bit OR operation resulting: 111011, in decimal: 59
6. Pointer Operators
The lecturers said that this kind of operator will be discussed in further meetings. But these are what i gained:
Pointer Operators are divided into two:
& (Address of) which shows the address of data by each operand
* (value of) which shows the value of an operand
Wednesday, September 26, 2018
Wednesday, September 19, 2018
Formatted Input and Output
I thought all datas are the same, like i thought those datas aren't specifically differentiated. Indeed back then datas looked the same to me, all of them. But in this session, I was lectured about formatted Inputs and Outputs.
Here I have somethings that I learned,
int is for integers (decimal numbers) without floating points. There are some specific identifiers for longer datas (long int and long long int).
float is for decimal numbers with floating points. There are also some specific identifiers for longer datas (long float and long long float), and also double for only two digits of floating points.
char is for any characters that is in the files of computer inputs (that is registered in ASCII). Any character registered has ASCII values. There is one thing called string, it is basically an array of char.
Scanning and Printing are essential as well.
for scanning and printing, the inputs are in this identifications,
%d for integers, %ld for long integers, and %lld for long long integers.
%f for float/double, %lf for long float/double, %llf for long long float/double.
%c for char and %s for string.
Introduction to Algorithm and Programming
This was my first session of Algorithm and Programming in Binus University. I was introduced to Algorithm and programming. I was surprised, I thought it was really difficult and hard to do but it isn't really that bad.
I was relieved that actually Algorithm and Programming are based on real life events and procedures, and the only problem for me is coding.
First session, i am really blind to C++ which is the first Programming Language for Algorithm and Programming subject. It was really hard for me to submit my logic and transform it into codes which wasn't my favorite language at all.
But well, the lecturers did gave some good logic and I kinda enjoyed the introduction.
- 19th September 2018
Subscribe to:
Comments (Atom)