Tuesday, December 18, 2018

Self Refrection (Semester 1)

I firstly entered Binus University and thought

    "If i weren't wrong, this campus is home of expert programmers and stuffs."

Well, to be honest, I came here without any knowledge of IT. I only knew how to use a computer in daily basis use.

First weeks passed by, I struggled to keep up on Algorithm and Programming. I was afraid that I won't make it out and understand anything. But then, I got some friends in my Class that has sympathy over me.

Weeks passed by and I learnt so much until I actually reach the tops of the class. All are thanks to the educational system and also the classmates and lecturers I met.

Here's what I got in my thoughts after these past 4 months in a quote:

   "Life is never about being what is at the least of all, it is to obtain something better even after you        reach some points in life. It is all about growing up and passing torches to each other."

I thank all lecturers and my Laboratory Class LT-01. Thanks for this semester, I am grateful for all thinks that had happened.

Excelsior!

Wednesday, December 12, 2018

Sorting & Searching

This is the last session probably for the first semester, I would like to thank the lecturers in the Collaborative Learning class for Algorithm & Programming for this semester.

The last session talks about Sorting and Searching.

It basically is:

1. Sorting

It is for us to sort some data in a program with certain method. There are 5 sort methods that I learned from here, those are:

1. Bubble Sort
2. Selection Sort
3. Insertion Sort
4. Quick Sort
5. Merge Sort

2. Searching

This method is used to search data in a sorted data in a program. There are 3 search methods that I learned from this session, those are:

1. Linear Search
2. Binary Search
3. Interpolation Search

Thanks again for the semester, I am proud to make this blog as I learned much theories from the Collaborative Learning class in Binus University.

Wednesday, December 5, 2018

File Processing

In here I was taught of how i make programs that can process files, or basically manipulate files haha.

Here's how I open a file,

1. first we need to input a variable to represent the file.

Syntax:

FILE *fp;

2. And we open the file. for example, we want to write on a file called "output.txt" in data D.

Syntax:

fp = fopen("D:\\output.txt","w");   //w here means write

3. We use "fprintf" to print inside the txt file.

Syntax:

fprintf(fp,"Hello World!");

And the result is, there will be a text "Hello World!" inside output.txt in Data D.

Here's how I read it,

1. Input the variable like this.

Syntax:

fp = fopen("D:\\output.txt","r");   //r here means read

2. you can scan the data in the output.txt file by using "fscanf". Here's how it's done.

Syntax:

fscanf(fp,"%s",a);

//if we print a, it will be "Hello".

With all these lectures, it is said that file can be processed and manipulated through programs.

Wednesday, November 28, 2018

Structures and Unions & Memory Allocation

Here is what i got from this week's session:

Structure is much likely an array, but it runs on a logic called "record". It is used to make an array (two dimensional usually) in order.

Here's an example of how it's done:

struct data{
   char name[100];
   char NIM[10];
   int age;
   char campus[100];
}student[100];

Once we pick a certain index, the data structure will make it easier to find the data connected by each other data inside it.

Example: input 1, it will print out

a student's name, NIM, age, and campus "accordingly".


Function and Recursion

Basically in this session, we are taking about how we separate a program into different modules.
The main module is the one which we usually make as "int main" in C / C++, and there are many which are called "functions".

1. Function

In short programs, this would pretty much be useless. But, in long term and big-shot programs like applications, games, etc., this is so useful. A name of a function represents all of its "functions" which is already made in the initialization before we call the main module / int main.

Example:

int strlen(char s[100]){
     int i = 0;
     while(s[i]!=NULL){
          i++;
     }
     return i;    //this means the result value which will be returned after it is run by the function is i.
}


2. Recursion

Ever heard of loop and repetition right? This is just an implementation of loopings and repetitions inside a function, calling the function itself again and again until it fulfills some certain condition.

Wednesday, October 17, 2018

Pointers and Arrays

In this session I learned about Pointers and also Arrays, here are the purposes of each:

1. Pointer

Pointer is like to "point at" certain pointer-ed data. So it is a reference method in programming. If an operand is given pointer to a certain operand, each will change value once each value is changed. So the pointer gives a connection between two operands or more.

2. Array

Array is basically a set, set of data. Here is some examples,

Syntax:

char A[100];  //this initializes an array of char with size of 100
int B[100];  //this initializes an array of integers with size of 100

Wednesday, October 10, 2018

Program Control : Repetition

Ever heard of loops? Repetition in programming is it! Basically we are creating loops in programming and it is called "repetition"

Here are some types of repetitions in programming world:

1. For

Syntax :

for( initial value ; condition ; statement){
       statement;
       statement;      //this is a counted loop because we'll certainly know how many loops there are
       ................
}

2. While

Syntax:

while( condition ){
        statement;
        statement;
        ................    //this is a leading decision loop because the condition is located on the lead(top)                                       and the end of the loop isn't certain because it is not counted.
}

3. Do-while

Syntax:

do{
    statement;
    statement;   //this is a trailing decision loop, it needs a statement/action first before putting it into                              judgement whether the loops goes again or breaks.
    ................
}while( condition );

There are some statements that are used for doing some necessary things in loops, there are:

1. Continue

It is used to skip a loop, basically just saying that nothing happens in some certain of conditions.

2. Break

It is used to break a loop, so the loop ends if it fulfills the condition needed.