Operators, library routines and string handling Cambridge IGCSE Computer Science revision
Not started
Learn it
In plain words
Operators are the symbols that do the work in a program: they calculate, compare and combine. Library routines are ready-made pieces of code for common jobs. String handling is working with text.
6 things to know
- Arithmetic operators: + add, − subtract, * multiply, / divide, ^ raise to a power. So 2 ^ 3 is 8.
- DIV gives the whole-number part of a division and MOD gives the remainder. DIV(17, 5) is 3 and MOD(17, 5) is 2.
- Relational operators compare two values and give TRUE or FALSE: = equal to, <> not equal to, < less than, <= less than or equal to, > greater than, >= greater than or equal to.
- Logical operators: AND is true only when both conditions are true. OR is true when at least one is true. NOT reverses true and false.
- Library routines: MOD, DIV, ROUND and RANDOM. ROUND(3.14159, 2) gives 3.14. RANDOM() gives a random number between 0 and 1.
- String handling: LENGTH("Hello") is 5. UCASE("Hello") is "HELLO" and LCASE("Hello") is "hello". SUBSTRING("Computer", 1, 3) is "Com": three characters starting from position 1.
Worked example
A program must decide whether Number is even. Write the condition.
- An even number divides by 2 with no remainder.
- MOD gives the remainder: MOD(Number, 2).
- The condition is MOD(Number, 2) = 0.
Tips and tricks
- DIV and MOD go together: DIV is how many whole times it goes in, MOD is what is left over. 17 = 3 × 5 + 2.
- The first character of a string can be position 0 or position 1. The question will say which. Here it is 1.
It lands in your notebook with its questions as flashcards.
Operators, library routines and string handling: 7 questions and answers
These are the quiz’s questions. Do the quiz first, then come back here for the ones that got you.
What is the value of MOD(20, 6)?
6 goes into 20 three times, with 2 left over.
What is the value of DIV(20, 6)?
The whole-number part of 20 ÷ 6.
What is the value of 2 ^ 4?
2 × 2 × 2 × 2.
What is the value of LENGTH("Octopus")?
Count the characters.
The first character is position 1. What is SUBSTRING("Octopus", 1, 4)?
Four characters, starting at the first.
What is the result of (5 > 3) AND (2 > 4)?
AND needs both to be true, and 2 > 4 is false.
Which operator means "not equal to"?
For example, Guess <> Answer.
Quiz
7 questions
Tap an answer and you’ll see straight away whether it’s right, and why.
Worksheet
2 questions, 5 marks. Write your answers on paper, then check them.
Operators, library routines and string handling
Cambridge IGCSE Computer Science 0478 · 5 marks · papermunch.org
Name ______________________________ Date ______________
State the value of DIV(29, 4) and the value of MOD(29, 4).[2]
Show answerHide answer
DIV(29, 4) is 7 and MOD(29, 4) is 1. (4 goes into 29 seven times, remainder 1.)
Word holds "Papermunch". State the value of LENGTH(Word), of UCASE(Word) and of SUBSTRING(Word, 1, 5), where the first character is position 1.[3]
Show answerHide answer
10, "PAPERMUNCH" and "Paper".
Answers: Operators, library routines and string handling
- 1. DIV(29, 4) is 7 and MOD(29, 4) is 1. (4 goes into 29 seven times, remainder 1.)
- 2. 10, "PAPERMUNCH" and "Paper".



