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.

Wednesday, October 3, 2018

Program Control : Selection

In this lecture, I was lectured about selections program control in programming. We can use these following methods:

- If
- Switch Case
- "?:" Operator

The use is kinda alike, for each of every methods it is mostly like this:

Syntax:

if(condition){

    statement;           //This is for true value
    statement;
    ......

}

else {
 
    statement;      //This is for false value
    statement;
    ........

}


For Switch Case it goes this way:

Syntax:

switch(Variable):

case 'condition' : statement;    //this is kind of like first "if" on the case
                             ......
                             break;
case 'condition' : statement;       //this is the second selection if the value doesn't have true value on                                                          the first one
                             ........
                            break;
case default : break;    //this is for if on every case shows false value

Wednesday, September 26, 2018

Operator, Operand, and Arithmetic

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 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