Programming Fundamentals Flashcards
What is a data type?
The kind of values that can be used in a data item
What are some examples of data types?
Integer, float/real, character, string, Boolean
What are arithmetic operators?
A symbol that will perform an operation on numbers
What are the arithmetic operators?
+, -, *, /, ^, MOD, DIV
What is ^
Exponent (power of)
What data type is the variable ‘numberOfStudents’
Integer
What data type is the variable ‘circleArea’
Real/Floating point number
What data type is the variable ‘found’
Boolean
What data type is the variable ‘answer’
Character
What data type is the variable ‘studentName’
String
What type of data is a char
A single ASCII character such as A, b, 3, ! or space
What type of data is a string
Zero or more characters
What can you define other than variables
Constants
What are some examples of constants
const PI = 3.14157926535
const VAT = 0.2
const MAX_PLAYERS = 6
What is snake case
Words that are separated with an underscore, e.g. MIN_AGE
Why declare a constant instead of a variable?
This prevents the value from being changed accidentally by a part of code
It shows a programmer that the value should stay the same throughout the program
Can a constant ever change its value?
A constant cannot be changed when the program is running
A constant can be changed by a programmer before the program is compiled or translated
What is DIV used for
Integer division, also known as quotient
e.g. 31 DIV 7 = 4 (remainder 3)
What is MOD (modulus) used for
Used to find the remainder when dividing one integer by another
e.g. 31 MOD 7 = 3 (remainder)
What is MOD (modulus) used for
Used to find the remainder when dividing one integer by another
e.g. 31 MOD 7 = 3 (remainder)
What is represented differently in binary
Strings and numbers
What is the string “17” represented in binary as
0011000100110111
What is the integer 17 held in binary as
00010001
What are functions/casting
They are used to convert data types