1 Pertemuan 2 Algoritma dan Pemrograman Matakuliah: T0016/Algoritma dan Pemrograman Tahun: 2005 Versi: versi 2.

Slides:



Advertisements
Presentasi serupa
Pseudocode & Flowchart
Advertisements

1 Algoritma Bahasa Pemrograman dan Bab 1.1. Pengertian Algoritma.
KONTROL ALUR EKSEKUSI PROGRAM
Function.
© aSup-2007 PENGENALAN SPSS   1 INTRODUCTION to SPSS Statistical Package for Social Science.
Pemrograman Berorientasi Objek Bab 1 – Pemrograman Terstruktur.
2. Introduction to Algorithm and Programming
Alg&Pemrog 2B Sistem Komputer Variable  Variable dapat didefinisikan sebagai bagian dari memory untuk menyimpan nilai yang telah ditentukan.  Setiap.
Fungsi Lecture 7. Motivation Complexity of programming problem  more difficult to consider the solution as a whole  clue: dividing the problem into.
OPERATOR OVERLOADING The ability to provide the operators with a special meaning for a data type but its original meaning is not lost. Example: Operator.
STRUCTURAL CONTROL STATEMENT  If  If…..else….  If ….elseif…else.
Review :: Kisi-kisi UTS ::
Struktur Data Ali Mustopa, S.KOM.
SUBPROGRAM IN PASCAL PROCEDURE Lecture 5 CS1023.
Dasar Pemrograman Java Nana Ramadijanti Laboratorium Computer Vision Politeknik Elekltronika Negeri Surabaya PENS-ITS 2008.
Dasar Pemrograman Java Pertemuan 2 Pemrograman Berbasis Obyek Oleh Tita Karlita.
Struktur Data & Algoritma Suryana Setiawan, Ruli Manurung & Ade Azurat (acknowledgments: Denny) ‏ 1 Fasilkom UI SUR – HMM – AAFasilkom UI - IKI20100/ IKI80110P.
1 DATA STRUCTURE “ STACK” SHINTA P STMIK MDP APRIL 2011.
Class and Object Introduction Specifying a Class Defining Member Function A C++ Program with Class Nesting of Member Functions Private Member Functions.
Structure Data - Array Pertemuan 7 Matakuliah: T0456 / Algoritma dan Metode Object Oriented Programming Tahun: 2007.
Variabel, Type, Konstanta Ekspresi dan Assignment KU-1072: P T I - B.
Pertemuan Operasi Seleksi
REPETITION CONTROL STRUCTURES
Pendahuluan Definisi :
FUNCTIONS Pertemuan 9 Matakuliah: T0456 / Algoritma dan Metode Object Oriented Programming Tahun: 2007.
INTRODUCTION TO SPSS Statistical Package for Social Science 1.
1 Diselesaikan Oleh KOMPUTER Langkah-langkah harus tersusun secara LOGIS dan Efisien agar dapat menyelesaikan tugas dengan benar dan efisien. ALGORITMA.
1 Pertemuan 1 Algoritma Matakuliah: T0456 ~ Algoritma dan Metode Object Oriented Programming Tahun: 2005 Versi: 5.
Dasar Pemrograman Java Pertemuan 2 Pemrograman Berbasis Obyek.
1 Pertemuan 2 Function & Pointer Matakuliah: T0044/Pemrograman Berorientasi Obyek Tahun: 2005 Versi: 1.0.
Menulis Kolom  Kolom adalah opini atau artikel. Tidak seperti editorial, kolom memiliki byline.  Kolom Biasanya ditulis reguler. Biasanya mingguan atau.
1 Pertemuan 09 Kebutuhan Sistem Matakuliah: T0234 / Sistem Informasi Geografis Tahun: 2005 Versi: 01/revisi 1.
1 Pertemuan Fungsi Matakuliah: T0016 / Algoritma dan Pemrograman Tahun: 2007 Versi: 6.
1. Pada akhir pertemuan ini, diharapkan mahasiswa akan mampu :  Mendemonstrasikan penggunaan fungsi serta pengiriman parameter 2.
1 Pertemuan 12 Pengkodean & Implementasi Matakuliah: T0234 / Sistem Informasi Geografis Tahun: 2005 Versi: 01/revisi 1.
Matakuliah : T0016 / Algoritma dan Pemrograman Tahun : 2007 Versi : 6
IKI 20100: Struktur Data & Algoritma Ruli Manurung & Ade Azurat (acknowledgments: Denny, Suryana Setiawan) 1 Fasilkom UI Ruli Manurung & Ade AzuratFasilkom.
1 Pertemuan 2 Voltage and Current Laws Matakuliah: H0042/Teori Rangkaian Listrik Tahun: 2005 Versi:
Pertemuan 07 Peluang Beberapa Sebaran Khusus Peubah Acak Kontinu
1 Pertemuan 11 The Manipulative part of the object data model (Lanjutan bagian 2) Matakuliah: M0174/OBJECT ORIENTED DATABASE Tahun: 2005 Versi: 1/0.
1 Pertemuan 5 Komunikasi antar Proses / Interprocess Communication (IPC) Matakuliah: T0316/sistem Operasi Tahun: 2005 Versi/Revisi: 5 OFFCLASS01.
1 Pertemuan 8 Array & Pointer of Class Matakuliah: T0044/Pemrograman Berorientasi Obyek Tahun: 2005 Versi: 1.0.
1 Pertemuan > > Matakuliah: >/ > Tahun: > Versi: >
1 Pertemuan 3 Instruksi Mesin dan Program: I Matakuliah: T0324 / Arsitektur dan Organisasi Komputer Tahun: 2005 Versi: 1.
1 Pertemuan 1 Pengenalan Pemrograman Terstruktur C Matakuliah: H0112 – Pemrograman Bahasa Tingkat Tinggi Tahun: 2005/2006 Versi: xxx/2.
Binary Search Tree. Sebuah node di Binary Search Tree memiliki path yang unik dari root menurut aturan ordering – Sebuah Node, mempunyai subtree kiri.
OPERATOR DAN FUNGSI MATEMATIK. Operator  Assignment operator Assignment operator (operator pengerjaan) menggunakan simbol titik dua diikuti oleh tanda.
Cursor MI2163 Dasar Pemrograman Basis Data. Introduction Cursor merupakan suatu variabel yang digunakan untuk menampung hasil query yang terdiri atas.
Visual Basic for Aplications in powerpoint. What is Visual Basic for Aplications? Visual Basic for Applications (VBA) is a very powerful objectoriented.
Dasar query basis data dengan SQLite
Bahasa Pemrograman (Pemrograman Visual)
While … do … Repeat … until … For … to … do …
Elemen Dasar C++ Norma Amalia, ST.,M.Eng.
Teknik. Pemrog. Terstruktur 2
DIG1G3 Implementasi Struktur Data
Konsep pemrograman LOOP
Pengujian Hipotesis (I) Pertemuan 11
Matakuliah : I0014 / Biostatistika Tahun : 2005 Versi : V1 / R1
Pertemuan 3 Variabel/Dinamik Pointer
Dasar-Dasar Pemrograman
Pertemuan 24 Teknik Searching
Pengenalan Program Java
Algorithms and Programming Searching
Pendugaan Parameter (II) Pertemuan 10
Recursive function.
PEMROGRAMAN JAVA.
Pemrograman, Bahasa C dan Jenis Data Utama
© Mark E. Damon - All Rights Reserved Another Presentation © All rights Reserved
Teknik. Pemrog. Terstruktur 2
Bahasa Pemrograman (Pemrograman Visual)
Transcript presentasi:

1 Pertemuan 2 Algoritma dan Pemrograman Matakuliah: T0016/Algoritma dan Pemrograman Tahun: 2005 Versi: versi 2

2 Learning Outcomes Pada akhir pertemuan ini, diharapkan mahasiswa akan mampu : Menjelaskan hubungan antara masalah- algoritma – program Pengenalan bahasa C

3 Outline Materi Hubungan antara program dengan algoritma Pengenalan bahasa C

4 Pemrograman Penulisan sejumlah kode tertentu untuk menyelesaikan suatu problem berbasiskan komputer Kode-kode tersebut dibuat sesuai algoritma yang diinginkan Program yang dibuat harus sesuai dengan format suatu bahasa yang digunakan

5 Hubungan masalah-algoritma-pemrograman Permasalahan : Menghitung jumlah N bilangan bulat >0 Solusi Algoritma : begin set jumlah=0 set c=1 input N repeat until c>N jumlah=jumlah +c c=c+1 loop display jumlah end implementasi Program Menggunakan compiler C/C++/VB dll

 2000 Prentice Hall, Inc. All rights reserved. 6 Chapter 2 - Introduction to C Programming Outline 2.1Introduction 2.2A Simple C Program: Printing a Line of Text 2.3Another Simple C Program: Adding Two Integers 2.4Memory Concepts 2.5Arithmetic in C 2.6Decision Making: Equality and Relational Operators

 2000 Prentice Hall, Inc. All rights reserved Introduction C programming language –Structured and disciplined approach to program design Structured programming –Introduced in chapters 3 and 4 –Used throughout the remainder of the book

 2000 Prentice Hall, Inc. All rights reserved A Simple C Program: Printing a Line of Text Comments –Text surrounded by /* and */ is ignored by computer –Used to describe program #include –Preprocessor directive Tells computer to load contents of a certain file – allows standard input/output operations 1/* Fig. 2.1: fig02_01.c 2 A first program in C */ 3#include 4 5int main() 6{6{ 7 printf( "Welcome to C!\n" ); 8 9 return 0; 10} Welcome to C!

 2000 Prentice Hall, Inc. All rights reserved A Simple C Program: Printing a Line of Text int main() –C++ programs contain one or more functions, exactly one of which must be main –Parenthesis used to indicate a function –int means that main "returns" an integer value –Braces ( { and } ) indicate a block The bodies of all functions must be contained in braces

 2000 Prentice Hall, Inc. All rights reserved A Simple C Program: Printing a Line of Text printf( "Welcome to C!\n" ); –Instructs computer to perform an action Specifically, prints the string of characters within quotes ( “ ” ) –Entire line called a statement All statements must end with a semicolon ( ; ) –Escape character ( \ ) Indicates that printf should do something out of the ordinary \n is the newline character

 2000 Prentice Hall, Inc. All rights reserved A Simple C Program: Printing a Line of Text return 0; –A way to exit a function –return 0, in this case, means that the program terminated normally Right brace } –Indicates end of main has been reached Linker –When a function is called, linker locates it in the library –Inserts it into object program –If function name is misspelled, the linker will produce an error because it will not be able to find function in the library

 2000 Prentice Hall, Inc. All rights reserved. Outline Initialize variables 2. Input 2.1 Sum 3. Print Program Output 1/* Fig. 2.5: fig02_05.c 2 Addition program */ 3#include 4 5int main() 6{6{ 7 int integer1, integer2, sum; /* declaration */ 8 9 printf( "Enter first integer\n" ); /* prompt */ 10 scanf( "%d", &integer1 ); /* read an integer */ 11 printf( "Enter second integer\n" ); /* prompt */ 12 scanf( "%d", &integer2 ); /* read an integer */ 13 sum = integer1 + integer2; /* assignment of sum */ 14 printf( "Sum is %d\n", sum ); /* print sum */ return 0; /* indicate that program ended successfully */ 17} Enter first integer 45 Enter second integer 72 Sum is 117

 2000 Prentice Hall, Inc. All rights reserved Another Simple C Program: Adding Two Integers As before –Comments, #include and main int integer1, integer2, sum; –Declaration of variables Variables: locations in memory where a value can be stored –int means the variables can hold integers ( -1, 3, 0, 47 ) –Variable names (identifiers) integer1, integer2, sum Identifiers: consist of letters, digits (cannot begin with a digit) and underscores( _ ) –Case sensitive –Declarations appear before executable statements If an executable statement references and undeclared variable it will produce a syntax (compiler) error

 2000 Prentice Hall, Inc. All rights reserved Another Simple C Program: Adding Two Integers scanf( "%d", &integer1 ); –Obtains a value from the user scanf uses standard input (usually keyboard) –This scanf statement has two arguments %d - indicates data should be a decimal integer &integer1 - location in memory to store variable & is confusing in beginning – for now, just remember to include it with the variable name in scanf statements –When executing the program the user responds to the scanf statement by typing in a number, then pressing the enter (return) key

 2000 Prentice Hall, Inc. All rights reserved Another Simple C Program: Adding Two Integers = (assignment operator) –Assigns a value to a variable –Is a binary operator (has two operands) sum = variable1 + variable2; sum gets variable1 + variable2; –Variable receiving value on left printf( "Sum is %d\n", sum ); –Similar to scanf %d means decimal integer will be printed sum specifies what integer will be printed –Calculations can be performed inside printf statements printf( "Sum is %d\n", integer1 + integer2 );

 2000 Prentice Hall, Inc. All rights reserved Memory Concepts Variables –Variable names correspond to locations in the computer's memory –Every variable has a name, a type, a size and a value –Whenever a new value is placed into a variable (through scanf, for example), it replaces (and destroys) the previous value –Reading variables from memory does not change them A visual representation integer1 45

17 Penutup Fungsi yang pertama kali dipanggil ialah main() Setiap bahasa pemrograman mempunyai format penulisan tersendiri Bahasa C mempunyai berbagai macam operator.