Professional Documents
Culture Documents
(a) Input
y
A set of information called data will be entered into the computer from keyboard, floppy disk, hard disk etc. and stored in a portion of the computer memory. This input which is an input to the computer will then be processed to produced the desired result.
(b) Process
y
Data control and storing, numerical comparison and arithmetic handling being done to the input to get the output.
(c) Output
y
The processed data which produced certain result is known as the output. The output data will be presented in a sheet of paper through the printer or display on a monitor
Carta Alir
Simbol Makna Arah aliran Mula / Tamat Input/output Proses Pilihan Penghubung Offpage connector Predefined Process
Annotation
7
Analysis: - Understand the problem Design: - How to develop solutions (Algorithm) - How flowchart works - How to construct flowcharts
Coding is a process of converting flowchart to program code (source code) But, before you can start doing this, you should learn some basics including the language itself.
Start
Read A Read B
Stop
Error 1: Call to undefined function printf Were trying to call a function that is not recognized by the compiler.`
Error 3: Undefined symbol A Were trying to use a variable but it has never been defined. Compiler doesnt recognize it
11
Errors we found just now are called syntax errors. y Syntax means rules of a programming language y You will get syntax errors if you do not follow the rules
y
12
13
Structure of a C program
14
15
Comment
Comment is a statement that is not executed. y Compiler will ignore all comments in your program y It is used to describe part of your program; makes your program more readable. y This helps people and also yourself to understand your codes.
y
16
Examples of comments
17
Identifiers
A symbolic name of data, functions or other objects. OR y An Identifier is a name for a variable, type, type member, template, class, function, namespace etc and is usually limited to letters, digits and underscores.
y
E.g: main => symbolic name of main function printf => symbolic name of a function that prints output onto the screen Rules for identifiers: 1. First character must be alphabetic character or underscore 2. Must consist only alphabetic characters, digits, or underscores 3. First 31 characters of an identifier are significant 4. Cannot duplicate a reserved word
18
Example: Valid Names: a student8 student_name _person_name TRUE FALSE Invalid Names: $a 3name person name int what?
19
20
Nyatakan sama ada pencam takrifan pengguna berikut sah atau tidak:
Pencam 1 Pencam_yang_terpanjang_sekali 23-JlnDuku Jalan#2 Kadar_Ke2 RM1200 $500 S100% Jalan_Duku BAB10 HEADLINE_TODAY MAIN void int
Tidak sah Sah Tidak sah Tidak sah Sah Sah Tidak sah Tidak sah Sah Sah Tidak Tidak Tidak Tidak
21
22
Integer types
23
FloatingFloating-point types
24
Some strings
25
26
27
28
29