Character Codes & String Conversion Flashcards

All 4 cards in this deck

What is a string conversion (casting)?

Converting a value from one data type to another, e.g. STRING_TO_INT('25') converts the string '25' to the integer 25.

Why does keyboard input often need converting before it is used in a calculation?

In most languages keyboard input is read as a string, so it must be converted to an integer or real (e.g. with STRING_TO_INT) before arithmetic is done on it.

Which AQA pseudo-code functions convert between strings and numbers?

STRING_TO_INT and STRING_TO_REAL convert a string to a number; INT_TO_STRING and REAL_TO_STRING convert a number to a string.

What do CHAR_TO_CODE and CODE_TO_CHAR do?

e.g. given that the character code for 'A' is 65: CHAR_TO_CODE('A') and CODE_TO_CHAR(66)

CHAR_TO_CODE returns the character code of a character and CODE_TO_CHAR returns the character for a code, giving 65 and 'B'.