0% found this document useful (0 votes)
9 views18 pages

Open CAIE-IGCSE-Computer Science - Practical

The document outlines various programming constructs including input/output operations, control structures (like loops and conditionals), and array manipulations. It also covers file handling, string operations, and the declaration of procedures and functions. Additionally, SQL query examples are provided for data retrieval and aggregation.

Uploaded by

Mahad Arif
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views18 pages

Open CAIE-IGCSE-Computer Science - Practical

The document outlines various programming constructs including input/output operations, control structures (like loops and conditionals), and array manipulations. It also covers file handling, string operations, and the declaration of procedures and functions. Additionally, SQL query examples are provided for data retrieval and aggregation.

Uploaded by

Mahad Arif
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 18

INPUT Name

OUTPUT "Hello Mr." , Name

// Alternatively //

READ Name
PRINT "Hello Mr," , Name

DECLARE [Variable Name] : [DATATYPE OF VARIABLE]

DECLARE [ARRAYNAME] : ARRAY [Lower Limit : Upper Lim

[VARIABLE NAME] <---- [Value to be assigned]


ArrayName [IndexValue] <---- [Value to be assigned]
FOR…TO…NEXT : Will run for a determined/known

IF [BOOLEAN VARIABLE]
THEN
OUTCOME
ELSE
OUTCOME
ENDIF

IF ((CONDITION 1) OR ( CONDITION 2)) AND (CONDITION


THEN
OUTCOME
ELSE
OUTCOME
ENDIF
MaxiumumValue <--- Array[1] MinimumValue <--- Array[
FOR Counter ← 2 TO LoopLimit
IF Array[Counter] > MaximumValue
THEN
MaximumValue ← Array[Counter]
ENDIF

IF Array[Counter] < MinimumValue


THEN
MinimumValue ← Array[Counter]
ENDIF
NEXT Counter

// Average//

Total ← 0
FOR Counter ← 1 TO NumberOfValues
Total ← Total + StudentMark[Counter]
NEXT Counter
Average ← Total / NumberOfValues

Total ← 0
FOR Counter ← 1 TO LoopLimit
Total ← Total + ValueToBeTotalled
NEXT Counter
INPUT Value
Found ← FALSE
Counter ← 0
REPEAT
PassCount ← 0
IF Value = Array[Counter]
FOR Counter ← 1 TO LoopLimit THEN
INPUT Value
Found ← TRUE
IF Value > Range ELSE
THEN Counter ← Counter + 1
PassCount ← PassCount + 1 ENDIF
ENDIF
UNTIL Found OR Counter > NumberOfValues
NEXT Counter IF Found
THEN
OUTPUT Value , " found at position " , Counter, "
ELSE
OUTPUT Value , " not found."
ENDIF
First ← 1
Last ← 10
REPEAT
Swap ← FALSE
FOR Index ← First TO Last - 1
IF Array[Index] > Array[Index + 1]
THEN
Temp ← Array[Index]
Array[Index] ← Array[Index + 1]
Array[Index + 1] ← Temp
Swap ← TRUE
ENDIF
NEXT Index
Last ← Last - 1
UNTIL (NOT Swap) OR Last = 1
OUTPUT "Enter the value "
REPEAT
INPUT Value
IF Value <> DIV(Value, 1)
THEN
OUTPUT "This must be a whole number, please re-en
ENDIF
UNTIL Value = DIV(Value, 1)

REPEAT
INPUT Value
IF Value < MinimumValue OR Value > MaximumValue
THEN OUTPUT "Please enter the value "
OUTPUT "The student's mark should be in the range" REPEAT
ENDIF INPUT Value
UNTIL Value >= MinimumValue AND Value <= MaximumValu IF Value = ""
THEN
OUTPUT "*=Required "
ENDIF
UNTIL Value <> ""

OUTPUT "Please enter your value of ", Limit , " cha


REPEAT
INPUT Value
IF LENGTH(Value) <> Limit
THEN
OUTPUT "Your value must be exactly" , Limit ," cha
ENDIF
UNTIL LENGTH(Value) = Limit

OUTPUT "Please enter your value "


REPEAT
INPUT Value
IF LENGTH(Value) > UpperLimit OR LENGTH(Value) < Lo
THEN
OUTPUT "Too short or too long, please re-enter "
ENDIF
UNTIL LENGTH(Value) <= UpperLimit AND LENGTH(Value)
OPENFILE "filename.txt" FOR WRITE

//When opening a file to write, all the data already

WRITEFILE "filename.txt" , Value

// The next command of WRITEFILE would be writen on

CLOSEFILE "filename.txt"

OPENFILE "filename.txt" FOR READ


READFILE "filename.txt" , Variable
// The value in the line (which is identified by the
CLOSEFILE "filename.txt"

OPENFILE "filename.txt" FOR READ


DECLARE DataVariable : STRING // Now the text written is commented and thus ignore
WHILE NOT EOF("filename.txt) DO
READFILE "filename.txt", DataVariable ""
// here the line can be outputted or stored in an a This method can also be used to comment
//before the file ends has been read multiple lines but the singular line method
ENDWHILE is more widely accepted and reccomended too
""
LENGTH("Text Here")

LENGTH(Variable)

SUBSTRING("Computer Science", 10, 7)


// returns the next 7 values starting from the 10th
SUBSTRING(Variable, Position, Length)

UCASE("Text here")

UCASE(Variable)

LCASE("Text Here")

LCASE(Variable)
DECLARE [VariableName] : DataType AS GLOBAL
PROCEDURE ProcedureName ()
[Commands]
ENDPROCEDURE
//Calling/running the procedure
CALL ProcedureName()

PROCEDURE ProcedureName (ParameterName : ParameterDa


[Commands]
ENDPROCEDURE
//Calling/running the procedure
CALL ProcedureName (ParameterValue)

FUNCTION FunctionName (ParameterName : ParameterData


[Commands]
RETURN ValueToBeReturned
ENDFUNCTION
DECLARE Name : ARRAY[RowLower:RowUpper,ColumnLower:C

FOR ColumnCounter ← 0 TO 2
FOR RowCounter ← 0 TO 9
OUTPUT "Enter next value "
INPUT ArrayName [RowCounter, ColumnCounter]
NEXT RowCounter
NEXT ColumnCounter


SELECT (fieldsname)
FROM (tablesname)
WHERE (condition)
ORDER BY (sortingcondition) ;

SELECT SUM ( fieldsname )


FROM (tablesname)
WHERE (condition)
ORDER BY (sortingcondition) ;

SELECT COUNT ( fieldsname )


FROM (tablesname)
WHERE (condition)
ORDER BY (sortingcondition) ;

You might also like