Algoritma & Pemrograman – Pertemuan 8 (Review)

Okay, just to remind you readers, I won’t be explaining everything. If you wanna know more, search for it online, whether it be on Google or Wikipedia. It’s a pain to write too long, you know?

Moving on….

Today’s topic is about Files & Streams.

First up, Streams.

Stream is a sequence of characters. All input & output data are also considered to be a stream. C also see file as a stream. The purpose of a stream is for keeping key in data from keyboard need to be saved at secondary storage device as a data file.

When a C program runs, there are 3 types of streams that activated:

  1. Standard Input Stream
    • Controls input from keyboard.
  2. Standard Output Stream
    • Controls output stream to monitor.
  3. Standard Error Stream
    • Controls error messaging.

Note: Each stream is associated with a file.

Files is basically a massive collection of bits. I’ll tell you why: First, records is a collection of fields. Field is a collection of bytes. Third, bytes is a collection of bits.

So, in short, file is a record. The rest are self-explanatory.

For more explanations, please search it yourself, like I said before.

Posted in BINUS University, Lessons, Review | Leave a comment

Algoritma & Pemrograman – Pertemuan 7 (Review)

The topic for the day is about Function & Recursion. I’m gonna write the basics only. If you want to know more, search it on Google or Wikipedia or any other website that might provide you with the necessary information that you inquire.

Moving on…..

Programs are divided into modules. This is where functions comes in. Functions are for implementing modules in programming.

Function itself is formed by grouping several statements for a designated purpose.

Mind you, functions are divided into two:

  1. Library Function. This is a ready-to-use one, provided by C Compiler.
  2. User-defined Function. You already what this means. It means functions that are made by the user.

I won’t go into more details on function. Moving on to Recursion.

Recursion is a function that could call itself repeatedly. This type is usually found in certain functions only. It is useful for recursive problems & Fibonacci sequence.

There is one rule when you want to use your own function. That is: place it above int main. This is due to the fact that main will only run the functions before it, thus making a custom function useless should one not place it above int main.

For more details, search for it online. Like I said, I don’t wanna write too long. It’s a pain.

Posted in BINUS University, Lessons, Review | Leave a comment

Algoritma & Pemrograman – Pertemuan 6 (Review)

Algorithm, is basically divided into 3 steps:

 

  1. I: Input
  2. P: Process
  3. O: Output

In Process, there are several process, such as:

  1. Selection (if, if-else, else-if)
  2. Looping (while, for, do-while)
  3. Storage

Basically, it’s the summary of all the sessions that were held in the past. I’m not gonna write any more info. It’s too much of a pain in the ass.

 

Posted in BINUS University, Lessons, Review | Leave a comment

Algoritma & Pemrograman – Pertemuan 5 (Review)

Pointer & Arrays

  • Pointer
    • Basically, variable that functions as a storage for another variable.
    • Syntax:

<type> *ptr_name;

  • Most used operator in pointer:
    • * (Content of)
    • & (Address of)
  • Example:

int i, *ptr;

ptr = &i;

 

(Using number)

int 3, *ptr;

ptr = &3; (This shows that the pointer stored the variable 3 inside it)

 

  • Pointer to Pointer
  • Basically, a pointer inception (Pointer that stores another pointer).
  • Syntax:

<type> **ptr_ptr;

  • Example:

int i, *ptr, **ptr_ptr;

ptr = &i;

ptr_ptr = &ptr;

 

(Using numbers)

int 5, *ptr, **ptr_ptr;

ptr = &5;

ptr_ptr = 5;

(This means that the pointer is pointed towards the “I” from the original pointer, which has the value of 5.)

 

 

  • Array(s)
    • Basically, data saved in a certain structure to be accessed in groups or individually.

Data(s) that were saved using the same name are distinguished by their index.

  • Characteristics of Array(s):
    • Homogenous
      • All elements have similar data types
    • Random Access
      • Doesn’t have to be in order. Can be accessed separately.
  • Syntax:

type array_value [value_dim];

  • Example:

int A[10];

  • Array(s) are consisted of these 4 components:
    • Type specified
    • Identifier (name of array)
    • Operational Index ( [ ]  )
    • Dimensional value inside operator [ ]
  • Keep in mind that these are still for one dimensional array. The next will be for above one dimension.

 

  • Array Initialization
    • Array(s) can be initialized without dimensional value declaration.
    • Example (No Dimension):

int B[ ] = {1, 2, -4, 8};

This means that the array has 4 elements.

1           2         -4           8

B[0]      B[1]      B[2]     B[3]

  • Example (With Dimension):

int B[8] = {1, 2, -4, 8};

1           2         -4           8           0           0           0           0

B[0]      B[1]      B[2]     B[3]     B[4]      B[5]      B[6]      B[7]

  • Example (Error):

int B[4] = {1, 2, -4, 8, 9}; -à Error

Error in result, caused by smaller dimension than given elements.

 

 

  • Accessing Array
    • There are two ways to access the element i = 2:

*(A + 2) or A[2]

  • A is equal to A[0] or a constant pointer to the first element of a particular array.
  • To show A[2] on the screen, there are two ways:
    • printf(“%d”, A[2]);
    • printf(“%d \n”, *(A + 2) );

 

  • Pointer Constant & Pointer Variable
    • Pointer Variable: Basically, a pointer that’s rewritable at run-time.
    • Pointer Constant: Basically, a pointer that’s untouchable at run-time.
    • Array is Pointer Constant to the first element to the array. Can be filled with Pointer Variable.
  • Example:

int x = 10, y = 20;

int *ptr;

ptr = &x;

ptr = &y;

(Note: ptr used in this code is Pointer Variable)

  • Pointer Constant can only be initialized at definition time.
  • C Compiler doesn’t limit the numbers of the possible dimensions. Instead, it’s limited by our PC’s memory.
  • Syntax 2D Array:

type name_array [row][col];

  • Example:

int a[3][4]

  • Initialization: Using rmo (Row Major Order)
  • Example:

int b[2][2] = {1, 2, 3, 4 };

int b[2][2] = { { 1, 2 }, { 3, 4 } };

int b[2][2] = { { 1 }, { 3, 4 } };

 

int x[3][4] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};

int x[3][4] = { {1, 2, 3, 4},

{5, 6, 7, 8},

{9, 10, 11, 12}

};

int b[2][2] = {1, 2, 3, 4 };

int b[2][2] = { { 1, 2 }, { 3, 4 } };

int b[2][2] = { { 1 }, { 3, 4 } };

int x[3][4] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};

int x[3][4] = { {1, 2, 3, 4},

{5, 6, 7, 8},

{9, 10, 11, 12}

};

  • Syntax 3D Array:

type name_array[row][col][depth];

  • Example:

int x[3][2][4] = {{{1,2,3,4}, {5,6,7,8}},

{{11,12,13,14}, {15,16,17,18}},

{{21,22,23,24}, {25,26,27,28}}

};

void main() {

int x[4][3][5] = {{{1, 2, 3}, {0, 4, 3, 4}, {1, 2}},

{{9, 7, 5}, {5, 7, 2}, {9}},

{{3, 3, 5}, {2, 8, 9, 9}, {1, 2, 1}},

{{0}, {1}, {0, 1, 9}}

};

printf(“%5d”, x[2][1][3]);

}

  • Array of Pointer
    • Basically, an array with pointers in it.
    • Syntax:

type *array_name [value_dim];

  • Example:

int i;

int *ptr[4];

int x=1, y=2,  z=3, w=5;

ptr[0]=&x, ptr[1]=&y; ptr[2]=&z;  ptr[3]=&w;

for(i=0;i<4;i++) printf(“%d “,*ptr[i]);

Output : 1   2   3   5

  • Array of Character
    • Basically, it’s like Array of Pointer, but instead of pointers, it has characters in it.
    • Syntax:

char array_name[value_dim];

  • Example:

char name[40];

char ss[20]={‘B’,’I’,’N’,’U’,’S’};  (20 elements)

char ss[ ]= {‘B’,’I’,’N’,’U’,’S’};   (5 elements)

  • String
    • Basically, the previous one (array of character) that ends with null character ( or in ASCII = 0)
    • String constant or String literal:
      • Characters that are read between double quotes.
      • Example: “Welcome to Binus”
    • String constant is pointer constant, thus can be assigned to an array of character:
      • Example:

char name[40] = ”Amir”;  //ok

name = ”Amir”;   // error name is a constant pointer

Name[40]= “Amir”;  //error

  • A String constant can be linked during compile-time:

“Hello, ” “world”

Is similar to:

“Hello, world”

  • Example of string initialization:

char s[ ] = “BiNus”;

Is similar to:

char s[ ] = {‘B’, ‘i’, ‘N’, ‘u’, ‘s’, ”}

  • String as a data type is not known in C.
  • Difference of Char & String
    • Character in C is written between single quotes. Each uses one byte of computer memory.
      • Example:char ch=’A’;char ch=65;     //ASCII

        char ch=0x41; //ASCII

    • String is written between double quotes.
  • String manipulation
    • In Standard Library Function (header file string.h) provides functions to manipulate string:
      • strlen()
        • Return a value of string length; excluded null char
      • strcpy(s1, s2)
        • Copy s2 to s1
      • strncpy(s1, s2, n)
        • Copy first n characters of s2 to s1
      • strcat(s1, s2)
        • Adding string s2 to the end of string s1
      • strncat(s1, s2, n)
        • Adding n characters of string s2 to the end of string s1.
      • strcmp(s1, s2)
        • Comparing the value of string s1 & s2, if familiar returning 0
      • etc.

For more info, please search at Google.com or Wikipedia.org, or at ASCII official website, or whatever website that teaches you coding. This one is quite a pain in the ass to write, so pardon the complicated language.

Posted in BINUS University, Lessons, Review | Leave a comment

Algoritma & Pemrograman – Pertemuan 4 (Review)

PROGRAM CONTROL: REPETITION

> Basically, repeats a command or set of one for a certain amount of time.

> Number of repetition depends on the user, whether it’s defined during coding or during run-time.

> There are several repetition/looping operation:

  • for
  • while (Check first, then run)
  • do-while (Run first, check later)

Syntax:

1. for

              for(exp1; exp2; exp3) statement;

or

              for(exp1; exp2; exp3){

                statement1;

                statement2;

               …….

               }

              exp1 :  initialization

              exp2 :  conditional

              exp3 :  increment or decrement

exp1, exp2 and exp3 are optional

> exp1 & exp3 may consist of several expressions, separatedd with comma.

> Example:

             void reverse(char ss[])

{

int c,i,j;

for(i=0, j=strlen(ss)-1; i<j; i++, j–){

c=ss[i];

ss[i]=ss[j];

ss[j]=c;

}

}

> Infinite Loop: Basically, it’ll run forever, since there’s no stop condition. To end the loop, use “break”.

> Nested Loop: Basically, it’s like Inception, a.k.a loop in a loop. The repetition operation will start from the inner loop.

 

2. While

               while (exp) statements;

               or

               while(exp){

                 statement1;

                 statement2;

                  …..

               }

> exp is a Boolean expression. The result from executing this expression will either be true (not zero) or false (equal to zero).

> The evaluation of exp is done before the statements are executed.

 

3. do-while

                  do{

                      < statements >;

                  } while(exp);

> exp will continuously be executed while still true.

> The evaluation of exp is done after executing the statement(s).

 

In while operation, if exp value is false, the statement(s) may not be executed at all.

On the other hand, in do-while, the statement(s) will be executed at least once.

 

Difference between break & continue:

1. break

> Ends looping operation (for, while, do-while).

> Ends switch operation

 

2. continue

Skips the rest of the statements (subsequent to the skip statement)  inside a loop, and continue normally to a next loop.

 

For more info or examples, please search at Google.com . I’m too lazy to give one. It’s a pain.

Posted in BINUS University, Lessons, Review | Leave a comment

Algoritma & Pemrograman – Pertemuan 3 (Review)

Selection

> Basically, an instruction or set of one that may or may not be executed, with a predetermined condition as the deciding factor.

> Syntax type:

  • If
  • If – Else
  • Switch-case

> Syntax:

  1. If
  • if (boolean expression) statement;

or

  • if (boolean expression){

    statement1;

    statement2;

    ……

    }

If the boolean expression is true, then a statement or set of statements will be executed.

2. If – Else

  • if (boolean expression) statement1; else statement2;

or

  • if (boolean expression){statement1;

    statement2;

    ……

    }

    else {

    statement3;

    statement4;

    }

If boolean expression is true, then statement 1 or set of statement 1 will be executed. If false, then statement 2 or set of statement 2 will be executed.

3. Nested-If

  • if (boolean expression) statement1;if (boolean expression) statement2;

    if (boolean expression) statement3;

or

  • if (boolean expression) statement1;else

    if (boolean expression) statement2;

    else

    if (boolean expression) statement3;

  • Only occurs when the word IF appeared more than once within IF statement.

> Switch-case

  • Basically, only use this if the numbers in if-else is too much of a pain for you to calculate.
  • If matches with a case constant value, then it will execute related statement/s.
  • If nothing matches, it’ll execute default statement/s

Syntax:

  • switch (expression) {

    case constant1 : statements1; break;

    case constant2 : statements2; break;

    default : statements;

    }

> ?:

  • Similar to IF statement, but returns value.

Syntax:

  • condition ? then-expression : else-expression

Example:

  • if(a > b)

    max_value = a;

    else

    max_value = b;

    as

    max_value = (a > b) ? a : b;

Error Type

  1. Compile-Time Error
  • Caused by Syntax Error

2. Link-Time Error

  • Successfully compile, but caused link error
  • Caused by no object code at link time

3. Run-Time Error

  • Successfully compiled, but error at runtime.
  • Usually caused  by numerical operation such as: overflow, floating point underflow, division by zero, etc.

4. Logical Error

  • Wrong result caused by incorrect flow / algorithm.

 

For examples on Errors, please try coding with wrong codes at Visual Express C++, or you can search for screenshots of examples at Google. I’m too lazy to give one to you. It’s a pain.

Posted in BINUS University, Lessons, Review | Leave a comment

Algoritma & Pemrograman – Pertemuan 2 (Review)

Operator: symbol yang memproses nilai untuk menghasilkan nilai baru.

Operand: bagian spesifik data yang bisa dimanipulasi. Basically, variabel.

C =  A + B

(= dan +) >> Operator , (C, A & B) >> Operand

 

Berdasarkan jumlah operand, ada 3 jenis operator, yaitu:

  1. Unary Operator (1 Operand)
  2. Binary Operator (2 Operand)
  3. Ternary Operator (3 Operand)

Namun, jika berdasarkan tipe operasinya, operator dapat dikelompokan ke dalam beberapa grup, yaitu:

  • Assignment Operator
  • Logical Operator
  • Arithmetic Operator
  • Relational Operator
  • Bitwise Operator
  • Pointer Operator

Assignment Operator: Basically, sama dengan (=).

Contoh:

  • int x = 7/2  >>> Hasilnya adalah 3, bukan 3.5
  • float x = 3>>> Nilai dari float y adalah 3.00000

Modulo: Pembagian bersisa (%)

Contoh:

  • A=10%3 = 1 (10 dibagi 3 sisanya 1)

 

Increment & Decrement

Contoh:

  • N++ atau ++N >>> Berarti N=N+1
  • U– atau –U >>> artinya U=U-1

Conditional Statement

Syntax: exp1 ? exp2 : exp3;

Contoh:

  • if (a>b) z = a; else z = b;

z = (a > b) ? a : b;

 

  • int main ()

    {

    int code, discount=0;

    code=1;

    discount = (code == 1) ? 30 : 10;

    printf(” Item discount = %d \n”,discount);

    return(0);

    }

Logical Operator

Ada 3, yaitu:

  1. && : Dan
  2. || : Atau
  3. ! : Bukan

Bitwise Operator

  1. & : Dan
  2. | : Atau
  3. ! : Bukan
  4. ^ : XOR
  5. ~ : Komplemen
  6. >> : Shift Kanan
  7. << : Shift Kiri

For everything else, please search at Google. I’m lazy to write more. It’s a pain.

Posted in BINUS University, Lessons, Review | Leave a comment

Algoritma & Pemrograman – Pertemuan 1 (Review)

Algoritma

  • Basically, cara menyelesaikan masalah secara bertahap atau berurutan.

Advantage dari algoritma adalah:

  • Independen dari bahasa pemrograman manapun.
  • Bisa ditranslasikan ke dalam bahasa pemrograman manapun.
  • Hasil atau output selalu keluar sama.

Ada 2 cara membuat (merepresentasikan / menggambarkan) algoritma, yaitu:

  1. Menulis / Writing
    • Pseudo-code
    • Structured Language
  2. Gambar / Drawing
    • Flow Chart

Generally, penulisan algoritma adalah sebagai berikut.

  1. Start
  2. (Statements, Pseudo-codes)
  3. End

 

Sementara proses berjalannya algoritma adalah sebagai berikut.

Problem >> Process >> Solution

If specified lebih lanjut, proses berjalannya sebagai berikut.

Algorithm >> Source Code >> Executable code

In the process, berikut adalah tahapannya.

Writing Code >> Compile >> Test Code (Syntax Err) >> Executable Code >> Test Output (Output Err) >> Documentation

Setelah menemukan masalah, model untuk algoritma dikembangkan. Kemudian, algoritma didesain. Dari tahap itu kemudian berlanjut ke tahapan yang telah dituliskan di atas. Kode ditulis, kemudian dicompile. Setelah itu dites. Jika Syntax Error, berarti ada kesalahan saat menulis kodenya. Jika tidak, maka dijalankan Executable Code. Lalu dites output dari algoritma itu, apakah error atau tidak. Jika error, kesalahan bisa ada saat penulisan kode, atau bisa saat problem definition, model development, atau algorithm design. Jika tidak ada kesalahan, maka berlanjut ke tahap terakhir, yaitu Documentation.

Pseudo-code

  1. Input
  2. Output
  3. Compute
  4. Storing value to an identifier (Store)
  5. Compare
  6. Repetition (Loop) (Do-While, Repeat-Until)

Structured Theorem

Structured Theorem memungkinkan pemrograman komputer hanya menggunakan 3 control structure, yaitu:

  1. Sequence
    • Basically, commands atau pernyataan yang berurutan.
  2. Selection
    • Bisa memilih dari beberapa statement atau perintah
  3. Repetition (Loop)
    • Mengulang beberapa perintah atau pernyataan.

Bahasa Pemrograman

Ada 3 tingkatan dalam bahasa pemrograman, yaitu:

  1. Rendah / Low (Assembler)
  2. Sedang / Medium (C, Pascal, Fortran)
  3. Tinggi / High (Java, C++. C#)

Sebagian besar dari bahasa pemrograman tingkat tinggi merupakan OOP.

OOP (Object Oriented Program) merupakan bahasa pemrograman yang, basically, membuat atau memanipulasi objek tertentu dengan menggunakan bahasa pemrograman.

Objek: A specific element (dalam hal karakteristik) yang dapat dibedakan dalam dunia nyata.

OOP memiliki beberapa turunan, yaitu:

  1. Inheritance
    • Pewarisan sifat suatu objek ke objek lain yang punya sifat sama. Tidak wajib berarti tidak harus mewariskan. Tidak pasti ada, berarti bisa saja tidak ada yang diwariskan. Tidak terlihat publik, berarti bersifat private, tidak ada yang bisa mengakses selain pembuat.
  2. Encapsulation
    • Menjaga kode-kode agar tidak sembarang diakses user lain. Merupakan teknik privatisasi.
  3. Abstraction
    • Mengedit class (design, metode, data). Sifat class pasti diturunkan ke class lain. Wajib bisa diakses semua user, walaupun bisa saja tidak wajib, tergantung decision pembuatnya. Dan bersifat labil, artinya selalu berubah, tidak konstan.
  4. Interface
    • Tampilan kepada user. Wajib menurukan sifat, namun tidak labil seperti Abstraction. Tetapi, harus diimplementasikan & Main hanya boleh 1. (Interface boleh banyak).

Polymorphism: aksi yang memanipulasi benda, baik bentuknya maupun lokasi (urutan). Termasuk / disebut Overload Method.

 

Posted in BINUS University, Lessons, Review | Leave a comment

HTTP (HIMTI Togetherness & Top Performances)

HIMTI’s Logo

HTTP 2015

HTTP is an event held by HIMTI (Himpunan Mahasiswa Teknik Informatika), the student organization for the SoCS to welcome the new students of SoCS. Although technically the students are already a Binusian, this one is specifically for those who majors in one of the branches in SoCS, such as GAT, MAT (Mobile Application & Technology), CS (Cyber Security), and TI (Teknik Informatika). Every year they have a different theme for the event. For this year, it’s SHINE, short for Strengthening Harmony & Inspire New Experience. This event is supported by several sponsors & media.

And now, I’ll tell you guys what I think about the event.

It was good. The event was not bad, though I don’t like the idea of having to wake up early in the morning on weekends. The stages of the event (or parts?) were well organized. They had some interesting & fun parts, but the opening was boring. We had to listen to speeches from the leaders of the SoCS & HIMTI. Even though it’s a must, it’s just plain boring for us as students (no offence). The last parts were when things start to get “upbeat”. I said upbeat because it relieved us of our boredom & it was enjoyable. I’m not the kind of guy who likes to party, but it was good for once in a while. Overall,  the event was great & those who missed it will regret not participate in it.

Posted in BINUS University, FEP | Tagged , , , , , , , , , , | Leave a comment

Academic Orientation (FEP Binusian 2019)

As per of this post made, the Academic Orientation is still ongoing. So I’ll just say about it so far.

So… Let us begin.

The Academic Orientation, or AO for short, is the second part of the Orientation at BINUS University. The first part being the General Orientation (GO for short), which I’ve posted earlier, and the third part being the Campus Life Orientation (CLO). The purpose of AO is to introduce freshmans, such as myself, to the curriculum used in BINUS University. Since my major was in Game Application & Technology (GAT), which is a part of the School of Computer Science (SoCS), I got the basics of coding (Algorithm) & such. The GAT students were divided into two classes, LA & LB. We get to use 3 labs, 2 for LA & 1 for LB. But because of the screwed up schedule in Binusmaya (the online platform for BINUS students & teachers), we ran into problems. A lot of students missed the first day, and it made a lot of them missed the introduction to Algorithm. At least they managed to fix the schedule for the next week (though it’s quite a pain for us, students, since we got screwed for the rest of the week).

Based from what I was told about the AO, it supposedly spans for the 1st semester (maybe the 2nd too? I don’t know). But the actual AO that tells us the basics of GAT are only 2 weeks long, even that there are off days. The real schedule, by that I mean when we students begin to learn about GAT (not the basics), starts at September 22nd, 2015, one week after the basic AO ended. So, yeah… This is what I got about AO.

Posted in BINUS University, FEP | Tagged , , , , , | Leave a comment