Week 3: Compiler Directives, Data types, and Binary Representation Flashcards
What is cpp?
C preprocessor
What does the preprocessor do?
Creates a “new” version of your
program and it is this new program that actually gets
compiled
What is the format of the substitution Macro and what does it do?
define text1 text2
Tells the compiler to find all occurrences of “text1” in the source code and substitute “text2”.
What does the #undef … directive do?
Makes sure that defined(…) evaluates to false
What is the format of the include directive?
include
what does inline do?
When the compiler compiles your program, it will not compile it as a function. Rather, it just integrates the necessary code:
ex:
inline int max(int a, int b) {
return a>b?a:b;
}
Can inline function improve the speed of your program?
Yes
Where are inline functions often defined?
In header (.h) files
What is the main difference between a #define statement and a function call if they look similar?
define will run until completion until every variable is incremented (even post incrementation like “i++”)
A function call of similar type will return before the post incrementation
How many bits is UTF-8? UTF-16? UTF-32?
8-bits, 16-bits, and 32-bits respectively
What does A start at in UTF-8? a?
A: 0100 0001
a: 0110 0001
What is 1s complement form?
Every negative number is simply the positive number with EVERY single digit flipped
All whole number integers are stored in either?
Magnitude only or 2s complement
How many bytes does a character take?
1 byte
How many bytes does a short take?
2 bytes
How many bytes does an int take?
4 bytes
How many bytes does a float take?
4 bytes
How many bytes does a double take?
8 bytes
What is a quad word?
8 bytes / 64 bits
What is the format of a character declaration / initialization
char a;
a = ‘g’;
OR
char a = ‘g’;
NOTE: single quotes
For a computer to perform an arithmetic operation, the operands must be
The same size (number of bits) and the same type
In C, if a variable must be converted to another type, what is the preference?
The computer will always convert to the more complex representation (variable promotion)
What is variable promotion?
Promoting to the more complex representation
What is implicit conversion?
When data types are upgraded to become the same type (the largest) automatically