Computer science programming section Flashcards
Learn the programming section of computer science
What is the data type int?
Whole numbers only.
What is the data type float?
Numbers that have a decimal part.
What is the data type boolean?
Can only take 2 values usually true or false.
What is the data type char?
A single letter, number, symbol.
What is the data type string?
Used to represent text, is a collection of characters.
What is each data types allocated memory?
- int: 2 or 4 bytes
- float: 4 or 8 bytes
- boolean: 1 byte
- string: 1 byte for every character of string.
What is the mathematical operation for addition, subtraction and multiplication?
- Addition: +
- Subtraction: -
- Multiplication: *
What is the mathematical operation for division, exponentiation (to the power of ), quotient and remainder?
- division: /
- exponentiation: **
- Quotient: DIV
- Remainder: MOD or %
What is the assignment operator?
The assignment operator is used to assign values to constants or variables.
What are the comparison operators?
== : is equal to
!= : is not equal to
< : less than
> : more than
<= : less than or equal to
>= : more than or equal to.
Give the function of all string manipulator functions.
x.upper : changes all characters in string to upper case
x.lower : changes all characters to lowercase
x.length : returns the number of characters in a string.
x.left : extracts the first character from a string
x.right : extracts the last character from a string
x.substring(a,b) : extracts a string starting at position a with length b.
What do IF statements do?
IF statements allow you to check if a condition is true or false and carry out different actions on the outcome.
What are switch statements used for?
Used to check if a variable has specific values.
What are the drawback of switch statements?
They can only check the value of one variable.
IF statements can check if multiple conditions are true.
What are the advantages of switch statements compared to IF statements.
The advantage is they have a similar structure to IF statements but they give a neater way to test different values of a variable this makes them easier to maintain.