Algorithm & Programming Session #04

Back again to tell you the story of my journey in a place so called “class”. What kind sorcery that they have implanted into my knowledge? Let’s find out Shall we.

At that session, we talked about a topic called “Repetition” with these sub topics:

1. Repetition Definition

2. For

3. While

4. Do-While

5. Repetition Operation

6. Break vs Continue

So you might be wandering what is the definition of “repetition”. …. Wait seriously? You don’t know? Wow. Might as well explain. Imagine your life, Done.

But in programming the definition of repetition is, 1 or more set of instructions that is being repeated. Quite self-explanatory indeed.

There is three types of repetition/looping in programming:

– For, usually written in this kind of form:

for(expr1; expr2; expr3){
statement1;
statement2;
…….
}

expr1 : Initiation

expr2 : Condition

expr3 : Increment/Decrement

– While

while(exp){
statement1;
statement2;
…..
}

– Do – While

do{
;
} while(exp);

There are certain ways to tell the loop to stop. One of them is break.

Example on using break:

int main() {
int x = 1;
while (x<=10) {
printf( “%d\n”, x );
x++;
break;
}
return 0;
}

That means the program will only finish one loop.

Another Operator quite helpful is called Continue

Example of Continue:

int main() {
int x;
for(x=1; x<=10; x++) {
if (x == 5) continue;
printf(“%d “, x);
}
return 0;
}

That means the program will skip the number five.

Well that’s the end of my lecture. Thanks for reading ^^

 

Algorithm & Programming Session #03

Welcome again to my blog!

This time I’m going to talk about what I learned from my algorithm class at the 15th of October 2015.

The topic this time is Program Control Selection.

The Sub-Topics are :

–If : A type of instruction to tell the program to make a statement, if the statement is true, then the program will make it work

–If-Else :The same as the one above except it has 2 or more statements

–Nested If : occurs if the word IF appears more than the statement

–Switch-Case : A statement that can be used to replace if-else, usually used when you want to make alot of statements.

–?: Operator : Similar to if, but returns value.

 

–Error Types

There are several types of errors :

1. Compile-Time Error : Occurs if there is a syntax error

2. Link-Time Error : Usually caused when a file used to be linked to an object was lost.

3. Run-Time Error : Usually caused by numerical overflow.

4. Logical Error : caused by incorrect logic.

 

That basically it. Thank you for reading this pile of s-

Algorithm & Programming Session #02

In this post I’m going to talk about the lesson about Algorithm & Programming that took place at the 8th of October.

The topic for that day is : Operator, Operand, & Arithmetic.

There are three types of Operand :

1. Unary : A type of calculation using one operand

2. Binary : A type of calculation using two operands

3. Ternary : A type of calculation using three operands

There are also types of operator based on it’s operation type:

1. Assignment Operator, as told by the name, it is used mainly for assigning a type of data; ex: x=2, so the value of x is 2

2.Logical Operator, an operator using the true & false value using && and ||

3.Arithmetic Operator, mainly used for basic calculation such as addition +, subtraction -, multiply *, division /, modulo %, increment ++, decrement ++, priority ( ).

4.Relational Operator, using the true and false value, but with a certain functionality such as equality, not equal, less/more than, etc.

5.Bitwise Operator, used for calculating binaries from a certain data.

6.Pointer Operator

 

That’s basically it, so…. yeah :l

Thank you for reading ^^

 

Algoritma & Pemograman( Algorithm & Programming) Session #1

In this post I’m going to type about the meaning of Algorithm & Programming. If not I’ll get no scores JKPLSDONTKILLME.

What is algorithm? You might say algorithm are those codes thingamajic that programmers do. Well I guess it is those kind of things, but our activities can also be counted as a subject algorithm. For example your activities that you do from waking up to taking a cab to work is algorithm. BUT, it’s kinda stupid to call all your activities as algorithm, right???

Next is programming which you all probably know, But what is OOP? OOP stands for Object Oriented Programming. Seems self explanatory but let me explain so I can get more respect :3. Let’s think that objects that we use for programming are blueprints of a house, what we call programs are basically the characteristics of that house.Get it? No? THEN GET OUT.

Programming also has levels of difficulty!

1. Assembler are usually for low leveled coding.

2. Medium leveled consists of C, Pascal.

3. High leveled consists of C#,C++,Java.

Next is pseudocode (Which is kinda hard to pronounce), is a type of language that you use with algorithm.

That’s about it for my some sort of “review”.

And as always, Thank you for reading ^^