Operators, strings and codes questions and answers
Questions
Q1. Give the answers to the following: a) 10 mod 4 b) 15 mod 5 c) 7 mod 6 d) 12 mod 20
Q2. Give the answers to the following: a) 3 DIV 1 b) 10 DIV 5 c) 20 DIV 15 d) 20 DIV 5
Q3. Give the answer to the following: a) 4 + 2 * 2 b) 20 - 5 / 5 c) (20 + 10) * 2
Q4. A Boolean expression is made up of an OR, an AND and a NOT operator. State what in order you should evaluate the operators.
Q5. What is meant byh 'initialising a variable'?
Q6. Why do variables been to be declared?
Q7. Describe in general terms how the ASCII table is organised by saying what the order of the following is:
-
- capital letters
- small letters
- full stops and commas
- digits
Q8. What is the ASCII code for a) null b) space c) capital A
Q9. Explain why Ben comes before Benny when comparing strings.
Q10. Apart from ASCII, state two characters sets used in computing.
Answers
Q1. a) 2 b) 0 c) 1 d) 12
Q2. a) 3 b) 2 c) 1 d) 4
Q3. a) 8 b) 19 c) 60
Q4. NOT first, then AND, then OR
Q5. Initialisation is when you give a variable a starting value.
Q6. Variables need to be declared so that you can be sure what the starting value is at any time in a program. This will reduce the chance for bugs. It also allows the operating system to reserve the right amount of memory for the variable.
Q7. Full stops and commas, then digits, then capital letters and finally small letters.
Q8. In ASCII, null = 0, the space = 32 and A = 65.
Q9. B, e and n in both words share the same ASCII codes. After that in the word Ben, there is a null, which is ASCII code 0. this code is less than the ASCII code for n in Benny, so Ben goes before Benny.
Q10. E.g. EBCDIC, Unicode, UCS.