You are on page 1of 31

DASAR KOMPUTER DAN PEMROGRAMAN

OR
INTRODUCTION TO COMPUTER AND
PROGRAMMING
Administration
 GBPP and SAP is available upon request
 RPKPS is available upon request
 Class will be assisted by one senior student
 Official language is English
 Course materials will be available only in English
 Lectures will be given in Indonesian and English
 Questions can be asked in Indonesian and/ or English
 Answers to questions will be Indonesian and/ or English
 Quiz and exam questions are in English, but answers can be
in Indonesian and/ or English
Main reference book
 Kernighan, Brian and Ritchie, Dennis, The Ansi C
Programming Language, 2nd Ed.
 Available upon request and also available in:
 \\192.168.11.253\mahasiswa\DKP
 Username: mahasiswa
 Password: mahasiswa
Asisten Dosen kuliah DKP
 Mr.
Dosen kuliah DKP
 Hartono Pranjoto
 Jurusan Teknik Elektro
 Kepala Laboratorium:
 Instrumentasi
 Pemrosesan Sinyal Digital
 Sistem Mikro(prosesor)

 Extension 405
 Pengalaman dengan Fortran, C, Unix, Linux
 Banyak bekerja dengan Internet dan jaringan
Grading for DKP
 Grade for STS (Skor Tengah Semester)
 Project and assignment (40%)
 Midterm exam (60%)
 Activity in class (10%)

 Grade for SAS (Skor Akhir Semester)


 Project and assignment (40%)
 Final exam (60%)
 Activity in class (10%)
Philosophy of this class
 Learn on how to write robust program
 Learn about algorithm and process flow in
programming
 Programming language is the basic for many other
projects and classes (will follow later)
 Basic programming in this class is C language
 Encourage students to be fluent in one language
and later can use other languages
Fluent in programming
 Able to type and write codes (not just drag and
drop, which is for sissy)
 Students have to type in their own programming
codes into the computer and then run the program
 Students are not discourage to copy-paste from
other sources
 Dosen knows about professional codes and
introductory student codes
 Asisten can detect codes from Internet sources
The program written in this class
 Programs will be tested in class and commented
 Programs have to be handed in and tested on a
Linux computer
 Assignment grades are from results of the program
run on the Linux computer
 Programs must have enough comments to describe
the meaning of the statement
 Programs must be compiled using GCC under Linux
environment
When to write program
 During practice session in class (Monday & Tuesday
& Wednesday)
 Dosen will be available for consultation
 Questions will be answered during practice session
 Program related questions will be addressed during the
session
 During your own time
 Linux server will be up most of the time, consult with the
assistant about availability
 Linux server can be accessed from other labs within Teknik
Elektro
 Codeblock is a C IDE compiler
 GCC can be installed on Windows XP/ 7/ 8/ 10
Results of writing good programs
 Build robust programs
 Build (un)safe programs
 Think about bug possibilities
 Build clean programs
 Build readable programs
Why writing program
 Almost everything in life involves programming (car,
motorcycle, refrigerator, magic jar, etc)
 Cell phones is about programming
 I(pod-pad-phone) are full of programs
 Television set is full of programs
 Playmovies
 Menu from remote
 Save/ delete/ select channels

 Lifts, elevators, travelators are full of programs


 CD, DVD and Bluray players are about programs
 Most electronic devices involve programming
Life with programs
 Making motion pictures requires programming these
days
 Programmers can make very good money
 Programmingcell-phones (USD 70k/ yr)
 Web programmer (USD 75-100k/ yr)

 Programs can change lives


 Live support systems use programs (heart
pacemaker)
 CAT/CT scan, MRI, X-ray machines require
programs
Homework, programs, project
 No late homework's, programs and projects are accepted
 All works must be original works
 Students are encourage to work with other students but not
to copy their works
 Students are allowed to ask more senior students
 Dishonest work will result in severe penalty
 In the assignment you must write down:
 Your name
 Amount of time spent on the work outside class
 Fellow students you work with
 Fellow students contribution toward your work
Environment of DKP
 No fancy interface in programming
 Program is built using terminal interface (shell)
 Operating environment is UNIX (Linux RH16)
 Manual pages are available online on Unix
 Using ‘man’ page on Linux
 Using Google to find the description

 Help is available online and via the Internet


 Compiler is free software GCC
 Debugger is free software GDB
More on compiler
 Compiler to be used is GCC compiler
 GCC is also available for Windows (XP/ 7/ 8/ 10)
under the name Code Block ask your senior students
 Ask students at Instrumentation Laboratory:
 Obtain GCC for Windows
 Install GCC under Windows environment

 Programs could be developed under Windows


environment but ………..
 Test and grading will be performed exclusively
under Linux RH environment
Compiler
 Convert from higher level language into machine code
 This class uses gcc (GNU C Compiler) and usually soft
linked as cc
 Program will have extension .c
 Editing will be performed using vim
 Object code uses extension .o (for debugger gdb)
 Example: gcc -Wall infilename.c -o outfilename.o
 For debugging purposes:
gcc -g -O0 -Wall infilename.c -o outfilename.o
Flow of program writing in Unix
Few Unix command
 Login and logout
 File copy, rename, delete (cp, mv, rm)
 Directory create, delete, rename (mkdir, rmdir, mv)
 Directory move around (cd)
 Useful command less, more, cat, who
 Using man for help (section 1, 2, 3)
 Editor using vim (insert, delete, write, quit etc)
Connect to your Unix environment
 Turn on your workstation
 Go to ‘Start Menu’, ‘All Programs’, ‘PuTTY’, find PuTTY
Connect to your Unix environment
 On the ‘Host Name (or IP
Address)’ type in
<your_id_number>
@192.168.11.253
 <your_id> is your
abbreviated student ID
 Make sure port is ‘22’
Connect to your Unix environment
 Make the font a bit bigger
 To make it easier to see
 To make it easier to look on the screen
 Click on ‘Window’, ‘Appearance’, ‘Change’ font,
 Select font size 14
Connect to your Unix environment
When you login
 When asked for password, enter <your_id_number>
as the password, nothing will appear on the screen
 You will be asked to change the password
immediately
 When asked for the password, enter
<your_id_number> again and nothing will appear on
the screen
 Then enter your new password twice, but nothing will
appear on the screen
 If unsuccessful, repeat the step again
After successful login
 You should be able to login
 You should be able to change password
 You should be able to logout
 You should be able to login again and logout
 After completion of the above steps, raise both
hands
After you login
 You will get a terminal with black background and
white text
 You can open as many terminal as you want using
the same procedure
 Each terminal is similar to one computer of your own
 You can start writing your programs on each
terminal
Stop here and discuss about programs
We will get back here again later,
now we move to Lect-01 slides
After you login
 I suggest you create a folder or directory to contain
all of your C programs in your home directory
 Create your folder using command:
‘mkdir kuliah_dkp’ or ‘md kuliah_dkp’
 Go inside the folder using command:
‘chdir kuliah_dkp’ or ‘cd kuliah_dkp’
Step to create program
 Write your program using a text editor (Notepad in
Windows), you cannot use Word
 Most common editor in Unix nowadays is ‘vi’ or ‘vim’
 To start the command writing as follows:
‘vi hello_world.c’
 Usefull keys:
 ‘Insert’key to insert text
 ‘Delete’ key to delete text
 ‘Esc’ key to go to command mode
 Type ‘:x’ to save and exit; ‘:w’ to save and stay in the editor
 Type ‘:q’ to exit; ‘:q!’ to exit without saving
Compile the program
 After you create your program, compile your
program using gcc
 Use the following command:
‘gcc hello_world.c’
 If there is no error, you will get back to the prompt
 If there are errors, go to the editor and fix it and
compile again
 Output file of gcc is always ‘a.out’ unless you
specify otherwise
 Consult manuals for options (‘man gcc’)
Run the program
 To run the program use the command:
‘./a.out’
 Observe the output
 Raise both hands when you finish
Inventor of
GCC

Inventor of
other unix…
GPL,
copyleft

You might also like