Week 1 - Gemini Flashcards
(86 cards)
What is the purpose of the #include<iostream>
directive?
It tells the compiler and linker that the program will need to be linked to a library of routines that handle input from the keyboard and output to the screen (e.g.
What is the using namespace std;
directive used for?
The C++
standard divides names (like cin
and cout
) into subcollections called namespaces. This directive indicates that the program will use names defined in the std
namespace (where iostream
defines cout
and cin
). [cite: 67, 68, 69]
What is the significance of the int main()
function in a C++ program?
The main()
function is the entry point of every C++ program; it’s the function called when the program is run. The execution of all C++ programs begins with the main
function. [cite: 70, 71]
What do the curly braces {}
signify in the main()
function (and other functions)?
The open brace {
indicates the beginning of the function’s definition, and the closing brace }
indicates its end. Everything between these braces is the function’s body. [cite: 72, 73]
What does the return 0;
statement in the main()
function typically indicate?
It indicates that the program worked as expected without any errors during its execution. [cite: 74]
What is cout
in C++ and how is it used with the <<
operator?
cout
identifies the standard character output device (usually the computer screen). The insertion operator <<
indicates that what follows is inserted into cout
. [cite: 77, 79]
How are statements separated in C++?
Statements are separated with an ending semicolon (;
). [cite: 80]
What does it mean that C++ is a ‘statically typed language’?
When you use a variable in C++, you must specify the type of data that will be stored in that variable, and once chosen, this type cannot be changed. [cite: 81, 82, 83]
Why is it important to specify the data type of a variable in C++?
Data is stored in the computer as strings of 1s and 0s. Specifying the type tells the computer how to interpret these 1s and 0s (e.g., as binary numbers for integers, or character codes for chars). [cite: 85, 86]
Define ‘bit’.
A single binary digit. [cite: 88]
Define ‘byte’.
8 binary digits. [cite: 89]
How many bytes are in a kilobyte (in the context of computer memory)?
$2^{10}$ or 1024 bytes. [cite: 89]
How many bytes are in a megabyte (in the context of computer memory)?
$2^{20}$ or 1048576 bytes. [cite: 89]
What is hexadecimal notation?
A base-16 number system using characters $0,1,2,3,…,9,A,B,…,F$. [cite: 90]
What is a ‘variable’ in C++?
A symbolic name for storing information in memory. The value stored can be changed. Variables must be declared before use. [cite: 91, 93]
What is the basic syntax for declaring a variable in C++?
Type_of_data Name_Variable;
[cite: 94]
List the built-in C++ data type for Boolean values and its keyword.
Boolean, bool
[cite: 95, 97]
List the built-in C++ data type for characters and its keyword.
Character, char
[cite: 95]
List the built-in C++ data type for integers and its keyword.
Integer, int
[cite: 95]
List the built-in C++ data types for floating-point numbers and their keywords.
Floating point, float
; Double floating point, double
[cite: 95]
What values can a bool
variable hold?
true
or false
. [cite: 97]
How is a char
data type stored in memory?
As a number between 0 and 255, taking up exactly one byte. [cite: 100]
What is the ASCII code?
It associates an integer value for each symbol in the character set, allowing arithmetic operations on characters. For example, '9' - '0'
evaluates to 9 because their ASCII values are 57 and 48 respectively. [cite: 102, 103]
How does declaring a variable as char
versus int
affect input and output?
It makes an important difference to the type of input the program expects and the format of the output it produces. [cite: 104]