C Programming Flashcards
TRUE/FALSE: C is a portable language. (Bonus: What does portable mean?)
TRUE. C can be run across a variety of different environments without much modification.
TRUE/FALSE: A variable is volatile (and should use the keyword) if it should be optimized by the compiler for efficiency, since it’s going to change a lot.
FALSE: Volatile variables should not be optimized by the compiler.
What is the type of the variable foo in the following declaration:
const char * const foo [] = {
“abc”, “xyz”
}
An array of constant pointers to strings (pointers to characters).
I want to write code that uses a variable count to store the number of times a function foo() has been run. What keyword should I use to store count?
static. Will be initialized to 0, and will remain in scope throughout the code’s duration.
I want to write a single debug variable so that I can include print statements while developing but turn them off easily on release. What keyword should I use for debug?
extern. This way, I can store the debug variable in a “config” file and access it without much hassle.
Notably, you can just use header files for this instead. And probably should.
Which part of the following variable declaration is the declarator?
const char * bar = “abc”;
bar. The name of the variable.
TRUE/FALSE: The following code will compile without error (assume headers and everything unseen are correct):
int foo = 3;
int bar = ++foo;
TRUE.
TRUE/FALSE: Do-while loops exist in C.
TRUE.
Define scope.
Where the item is accessible in the program.
Define liveliness.
How long the variable remains in memory during execution.
Why do we use macros and inline assembly?
To access instructions that can’t work in regular functions.
TRUE/FALSE: Obfuscation is the practice of using functions, modules, and different files to manage the complexity of a large program.
FALSE: This describes abstraction, not obfuscation.
TRUE/FALSE: Obfuscation is a good way to hide information from users who call your code.
FALSE: Obfuscation makes code hard to manage; It does not describe the process of calling it directly (it might make understanding its general purpose more difficult).
TRUE/FALSE: Comments are the best way to make sure your code is readable.
FALSE: Writing clean code is the best way; Comments help good code but don’t make up for bad code.