0% found this document useful (0 votes)
129 views

Week1,2 Introduction To Programming

This document discusses an introduction to programming lecture covering programs, programming, programmers, and types of programming languages. It defines programs as sets of instructions that tell computers what tasks to perform. Programming is the process of designing programs, while programmers are people who write computer programs. Programming languages include low-level languages like machine language and assembly language as well as high-level languages. Examples of programming in C language are provided. Different programming paradigms like structured, modular, and object-oriented programming are also introduced.

Uploaded by

wfidayu
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
129 views

Week1,2 Introduction To Programming

This document discusses an introduction to programming lecture covering programs, programming, programmers, and types of programming languages. It defines programs as sets of instructions that tell computers what tasks to perform. Programming is the process of designing programs, while programmers are people who write computer programs. Programming languages include low-level languages like machine language and assembly language as well as high-level languages. Examples of programming in C language are provided. Different programming paradigms like structured, modular, and object-oriented programming are also introduced.

Uploaded by

wfidayu
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 28

Introduction to Programming (Week 1&2)

Lecture by: Pn. Wan Fazlini Idayu binti Wan Fakari

Discuss on: Program Programming Programmer

What is program?
A set of step-by-step instructions that tells a computer to perform a specific task and to produce the required results. written by the programmer Produced through programming

What is programming?
Programming is a process of designing/ creating a program. It is a communication technique to explain the instructions to the computer. Used to produce the program.

What is Programmer?
A Programmer is a person who designs, writes and test computer programs.

A programming language (1)


Is a set of instructions that can be used to construct a program. A notation for writing programs, which are specifications of a computation or algorithm. Is a language designed to describe a set of consecutive actions to be executed by a computer.
6

A programming language (2)


A programming language is therefore a practical way for us (humans) to give instructions to a computer. Programmer interacts with the computer by using a computer language).

Type of Programming Language

programmers talk to computer using a computer language. Generation of computer languages: - Low Level Language - High Level Languages
8

Type of Programming Language

Low Level Language: 1st : Machine language 2nd : Assembly language : The language structure depends on instruction set/ CPUs architecture.
* low level language enables efficient machine usage but it is difficult to use.
10

High Level Language:


3rd : Procedure oriented: COBOL, C, FORTRAN, Pascal 4th : Problem oriented/query : DATA-TRIEVE, INTELECT

11

Machine language
The lowest-level programming language Machine languages are the only languages understood by computers. easily understood by computers, but almost impossible for humans to use (because consist entirely of numbers). Expressed in binary form. Very difficult to use. Lowest level of computer languages. Example:
0101 0101 1000 1010 0001 1101 0000 0001 1100 1010 0001 0000 0000 0101 1111 0100

Assembly language (1)


Second level of language. An assembler translates assembly language. It was developed to replace "0" and "1" used in Machine Language. Machine languages consist entirely of numbers and are almost impossible for humans to read and write. Takes a long time to write programs.

Assembly language (2)


English-like abbreviations representing elementary computer operations (translated via assemblers). Example: L 1, GAJIKASAR S 1, CUKAI ST 1,GAJIBERSIH

High-level language
Instruction is written as a series of English-like words. Translator (Compiler/Interpreter) is needed to translate high level language to machine language. It is Machine-Independent. The program can be written and executed on any computer. Example: GAJIBERSIH = GAJIKASAR CUKAI

Examples of computer language(3) High Level Language


GAJIBERSIH = GAJIKASAR CUKAI

16

Translation
Computer only understands machine language. Computer program written in assembly language need to translate into machine language before it can be executed. The translation process from assembly language to machine language is done by computer program called assembler.
17

Translation
High level language also need to be translates into machine language before being executed.
The computer program that translates from high level language to machine language is called a compiler or an interpreter.

Bahasa Pengaturcaraan C
C ialah sebuah bahasa pengaturcaraan aras sederhana.

19

Sejarah bahasa C
Berasal dari bahasa BCPL oleh Martin Richards (1967). Ken Thompson mengembangkan bahasa BCPL menjadi bahasa B (1970). Berkembang menjadi bahasa C oleh Dennis Ritchie (1970-an) di Bell Telephone Laboratories Inc. (sekarang adalah AT&T Bell Laboratories). Bahasa C pertama kali digunakan adalah pada komputer Digital Equipment Corporation PDP-11 yang menggunakan sepenuhnya sistem pengoperasian UNIX.

20

How Computers Run the Program


computer program run through the following steps: Edit : Source code (type the program) Compile : If no syntax errors Object Code Link Run : Link to library function exe mode : Output (check for any semantic errors)
21

22

Examples of C programming:#include <stdio.h> main() { printf("hello, world\n"); return 0; }

23

Ex.2 (pengiraan markah)


#include <stdio.h> int main(void) { float u1, u2, pro; // markah dimasukkan oleh pemakai float berat_u1, berat_u2, berat_pro, jumlah; // berat markah // Input markah dari pemakai printf("Masukkan markah Ujian1 : "); scanf("%f", &u1); printf("Masukkan markah Ujian2 : "); scanf("%f", &u2); printf("Masukkan markah Projek : "); scanf("%f", &pro); // kira berat markah untuk ujian dan projek berat_u1 = (u1 / 100) * 30; berat_u2 = (u2 / 100) * 30; berat_pro = (pro /100) * 40; // kira jumlah markah jumlah = berat_u1 + berat_u2 + berat_pro; // Cetak ujian1, ujian2, projek, dan jumlah markah printf("\nTest 1 (30%) : %5.2f\n", berat_u1); printf("Test 2 (30%) : %5.2f\n", berat_u2); printf("Project(40%) : %5.2f\n", berat_pro); printf("Overall(100%): %5.2f\n\n", jumlah);
// Tentukan gred dan sama ada gagal atau lulus if (jumlah >= 80) { printf("Gred : A\n"); printf("Lulus!!!\n"); } else if (jumlah>= 70) { printf("Gred : B\n"); printf("Lulus!!!\n"); } else if (jumlah >= 60) { printf("Gred : C\n"); printf("Lulus!!!\n"); } else if (jumlah >= 50) { printf("Gred : D\n"); printf("Lulus : Mengulang\n"); } else if (jumlah >= 40) { printf("Gred : E\n"); printf("Gagal : Mengulang\n"); } else { printf("Gred : F\n"); printf("Gagal : Mengulang\n"); } return 0; }

24

Jenis-jenis pengaturcaraan
Structured programming (berstruktur) Modular programming Object-oriented programming (berorentasikan objek)

25

Structured programming
Guna pendekatan "top-down" untuk merekabentuk. Pendekatan top-down bermula dengan gambaran awal dari sistem yang mengandungi butiran minimum tentang bahagian-bahagian yang berbeza. Rekabentuk seterusnya dgn menambah butiran untuk meningkatkan bahagian selanjutnya sehingga selesai rekabentuk. The most popular structured programming languages include C, Ada, and Pascal.
26

Modular programming
Dipecahkan kepada beberapa modul. Break a large program into smaller independances modules.
p/s: find more information and make it as your assignment.

27

Object-oriented programming (OOP)


Berasakan objek dan visual

Bahasa generasi ke 4 (4GL)


2 konsep utama dalam OOP
1. 2.

Objek Kelas

The most popular object-oriented programming languages include Java, Visual Basic, C#, C++, and Python.
p/s: find more information and make it as your assignment.
28

You might also like