Chapter 2 Questions Flashcards
What is the meaning of the #include statement?
it tells the compiler what libraries need to be linked
What is the difference in a library (.h) that is between <> verses between “”?
<> is a prewritten library
“” is a user defined library
What is the library stdio.h for?
contains standard input and output functions such as scanf and printf
What is the library math.h for?
contains mathematical functions such as sqrt and pow
What are the four (4) valid options to define the main() function in C?
main(){…}
void main(){…}
int main(){… return 0;}
main(int argc, char *argv[]){…}
When you have a main() function defined with a type int, what does the statement “return 0;” mean?
the program ran as expected/ no errors or exceptions
In the statement “scanf(%d, &i)”, why do we use “&” in the second parameter?
to store the scanned value at the address?
What is the purpose of the %d, %f, %c, %s, and %p in the printf() function?
they are
What are the two (2) types of variables, scope-wise, that we have in C?
local and global
If C does not have boolean type variables, how are relational operations (needed in conditions and loops) handled?
if it returns a 0 it is false, if it returns any other number it is true
How many basic data types are there in C?
5 (int, double, float, char, void)
How is the scope of a variable defined in C?
it starts at the declaration and goes until the end of the block defined by {}
When declaring a variable/function in C, what does the rule “declaration-before-use” mean?
you cannot use a variable ahead of where it is declared (scope)
What is a forward declaration and why do we want to use it?
What are long, short, signed, and unsigned?
modifiers