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