5. Involves translating high-level language (programming language such as C,C++, Visual Basic, C#) Because computers do NOT understand high level language! Translated to Computer's machine language 00011101 01010101 11011111
6. Program Development Environment Typical program development environment consist of six phases to be executed. Edit/Write Preprocess Compile Link Load Execute
31. Program Development Environment Preprocessor Directive Format: #include <header file> or #include “user defined files” Example #include <stdio.h> #include <conio.h> #include “jam.h”
43. Every statements must be ended with semicolonDeclaration statement Function statement Types Control statement Input/Output statement Compound statement
44.
45. Differs in terms of colour : greyTo increase program readability To document a program Function As a future references To provide additional information
46. Program Development Environment Using references from any C book, find and study the following concepts (definition and examples): Reserved Word Variable Constant
47.
48. Contain special meaning understood by compilerRules Case –sensitive Must be written in small case Cannot be used as identifier or variables
49. Program Development Environment Reserved Word Example: int The acronym for integer void Refer to the function that will not return any value case default switch break for continue float double return while if do int
65. Program Development Environment 1 Declaration format: const data_type const_name = const_value; Data type const float pi = 3.142; Reserved word Constant Value Constant name
66. Program Development Environment 2 Declaration format: #define const_name const_value; Constant value #define pi 3.142; Reserved word Constant name
67. Program Development Environment Example of constant: #define minimum 0; #define MAX 100; const int counter = 100; const char alphabet = ‘J’; const float value = 4.5;
68.
69. Program Development Environment Declaration Example Declaration of a variable number of integer data type. int number; float weight; char alphabet; Declaration of a variable weight of floating point data type. Declaration of a variable alphabet of character data type.
70. Program Development Environment Variable/constant declaration example //Variable and constant declration #include <stdio.h> int number; float weight; void main() { const float pi =3.142; int bilangan; float berat; char abjad; } Variable declaration Constant declaration Variable declaration
71. Program Development Environment Variable and constant declaration example: //Variable and constant declaration #include <stdio.h> const float pi=3.142; void main() { int bilangan, bil, bilang; float berat, kg; char A; }
72.
73.
74.
75. Types of data to be stored and used in programming should be informed to the compiler/system Types Integer Character Floating point
78. Valid until 5 places of integer number.Integer Example: age is used to represent the age of students between 18 and 25 years old. The declaration for the variable is as follow:int age;
79.
80. Reserved word– double /floatExample: height is used to represent the student’s height between 150 cm and 180 cm. The declaration for the variable is as follow: float height;
81.
82. Reserved word – charCharacter Example: gender is used to represent the gender of a student. The declaration for the variable is as follow: char gender;
83. Program Development Environment Exercise: Determine whether the following identifiers is valid or invalid. Give reason for invalid cases. 1)Parit Raja 2) 20thCentury 3) int 4) INTEGER 5) _BMW2003 6) Reservedword 7) BIT1033 8) markah_pelajar 9) jam*kredit 10) printf
84. Program Development Environment Exercise: Write a suitable variable declaration for each of the following statement: i. Salary of an employee ii. Student’s mark for programming subject iii. ATM pin number iv. Phone number v. Price of one item vi. Bus seat number vii. Student name
85. Program Development Environment Exercise: Based on the following problem, determine the appropriate variables can be declared: Given the value of x is 10 and a is 12, find the result of the following equation: y = 2x + a - 6
86. Program Development Environment Exercise: Based on the following problem, determine the appropriate variables can be declared: MrsLeeya needs to determine her students grade for programming subject based on the mark scored during final examination. The ‘A’ grade will be given if the Mark scored is between 85 to 100. If a student has scored 90 marks, what is the grade should MrsLeeya give to the student?
87. Program Development Environment Exercise: Based on the following problem, determine the appropriate variables can be declared: A box has height, width and length. Calculate the volume of a box.
88. Program Development Environment Exercise: Based on the following problem, determine the appropriate variables can be declared: Uncle Degawan wants to buy 5 tins of paint from Cinda’s shop. The price of each tin of the paint is RM 15.60. Calculate the price which Uncle Degawan have to pay for all the tin of paints he bought.