2. CONSTANTS
IN A PROGRAM, VALUES THAT DOES NOT CHANGE UNDER A GIVEN SET OF
CONDITIONS
Use a unique identifier
Declared at the start of the program
Eg: CONST PI=3.14;
CONST VAT_RATE=0.2
3. USES OF DECLARING CONSTANTS
In case, if the value has happened to change, only need to change in one
place.
Easier to understand the code as instead of numbers identifiers have been
used.
4. VARIABLES AND DATATYPES
WHAT IS A VARIABLE?
A CHARACTERISTIC, QUANTITY OR NUMBER THAT INCREASES OR DECREASES
OVER TIME OR TAKES DIFFERENT VALUES IN DIFFERENT SITUATIONS.
int number=1;
Int:number
5. Date Type Type of data Amount of memory
Integer Whole number 2 bytes
Real A number with a decimal
part
4 bytes
Char A single character 1 byte
String Zero or more characters 1 byte per character
Boolean Either true or false 1 byte
DATATYPES AND MEMORY SIZE REQUIRED
6. NUMERIC DATA TYPES
DIV AND MOD
DIV- divides the number and gives the answer as a whole number.
13 DIV 4=3
MOD- divides the number and gives the remainder as a whole number.
13 MOD 4=1
7. ARRAYS
An array is a group of data items of the same data type stored under one
identifier one after another in memory locations.
8. BENEFITS OF AN ARRAY
Easier to follow the code and find bugs easily
Data can be processed using a FOR loop
9. ERRORS
Mainly there are two types of ERRORS
Syntax errors - misspelt code
Logic errors – even the code works, but it does not do what you want to do.
10. Syntax Errors
Translators expect to have a certain format known as syntax.
In Delphi,
VariableName : Datatype;
In java
int variableName;
What are the possible syntax errors?
11. Logic Errors
Even though the code works but we may not be able to achieve the expected
result. These are because of logic errors.
total=a-b*2
for(int i=10;i>10;i++){
print (i);
}
13. TESTING
Test purpose Test data Expected
Outcome
Actual Outcome
Design and Planning stage Final stage/Testing
If there is a range specified in the code, testing should be done
between the allowed ends and as well as not allowed ends.
This is known as testing boundary data or extremes.