Tugas algoritma 4

Pertemuan 22 Oktober 2015

Repetition

-Repetition is One or more instruction that is repeated for a certain amount of time.

-Number of repetition can be predefined(hard-coded) or defined at run-time.

-Operation:

  • for
  • while
  • do-while

Repetition:FOR

for{exp1;exp2;exp3}statement;

Infinite loop:Stop with break.

Nested loop:Loop within a loop.

Repetition While

Hanya berjalan bila statement true.

Repetition:Do-While:

Melakukan proses dulu lalu memeriksa statement.

Repetition Operation:

Break untuk memaksa menutup proses.

Tugas Algoritma 3

Presentasi 15 Oktober

Selection Defenition:An instruction or block of instructions may be executed (or not) with certain predetermined condition in a algorithm implementation

Selection If:

If boolean expression resulting in True, then a statement or some statements will be executed.

Selection If Else:

If boolean expression resulting in TRUE, then statement1 or  block statement1 will be executed, if FALSE then statement2 or block statement2 be executed

Selection Nested If:Appears if the word IF appears more than once during an IF statement.

Switch Case:Used in exchange of IF-ELSE,when if-else nested number of level is dificult to read.

The operator ?:Simmilar to the IF statement,but returns a value condition ? then- expression:else-expression

Error Type:

  • Compile-Time error
  • Link-Time error
  • Run-Time error
  • Logical error

Tugas Algoritma 2

Dari pertemuan 9 Oktober 2015

Operator:Symbol to process value result for a new value

-Binary operator:2

-Tenary operator:3

-Unary operator:1

Operator Type

  • Assigment operator
  • Logical operator
  • Arithmatic operator
  • Relational operator
  • Bitwise operator
  • Pointer operator

Assigment Operator

-Binary operator

-Used to assign value in a operation

-Syntax: Operand 1(L-value/variable)=Operand 2(constant)

Example:

  • x=2;  //constant
  • x=y;   //other variable
  • x=2*y   //expression
  • x=sin(y);   //function

Arithmetic Operator

Example:

N++;   Post increment

++N;   Pre increment

(equal to N=N+1 if standalone)

N–;   Post decrement

–N;   Pre decrement

(equal N=N-1 if standalone)

if bound sstatemenr(sub expression) then both of them have a diferent meaning

++n > n add by 1 then continue process

Arithmatic Operator

Relational Operator

++ : equality

!= : not equal

< : less than

> : greater than

<= : less equal than

>= : more equal than

Continoual Expression

Statement:if (a>b) z=a;

else z=b

Logical Operator

GG     AND

||     OR

!     NOT

Bitwise Operator

&     AND     A&B;

|     OR     A|B;

^     XOR     A^B;

~     Complement     ~A;

>>     Shift Rigth     A>>3;

<<     Shift Left     B<<2

 

 

 

Tugas Algoritma

1 Oktober 2015

Object Oriented Programing (OOP):

  • Inheritance
  • Abstraction
  • Interface
  • Polymorphism

Tingkat Bahasa Pemograman dari rendah sampai tinggi:

Assembler>C,Pascal,Fortran>Java,C++,C#

Problem>Process>Solution

Develop an algorithm:

  1. Writing
  2. Flowchart

Pseudocode:

  1. Input
  2. Output
  3. Compute
  4. Store
  5. Compiler
  6. Loop

Why C is popular:

  1. Flexibility
  2. Portable
  3. Well known programming langguage
  4.  Library Support

C standard library:

  • <math.h>
  • <stdio.h>
  • <stdlih.h>
  • <string.h>