CS50 Week 2 Flashcards
How many bits is an int?
32
How many bits is a long long
64
How many bits is a float?
32
How many bits is a double?
64
How many bits is a char?
8
Reminder: variables declared inside curly braces have scope limited to within the curly braces.
Reminder: variables declared inside curly braces have scope limited to within the curly braces.
How do you declare a global variable?
Declare it before main()
What is the function that gives a string’s length, and where is it found?
strlen(string)
string.h
How is a variable declared?
type name(parameter)
Type is the data type that will be returned
What is the type of a function that returns no value?
void
Where is a function declared?
The name should be declared above main()
The actual body of the function should be declared after main()
How many numbers can be represented by a 32 bit int?
2^32
roughly four billion
How do you cast numbers into a type while in an equation?
(float) 1
(float) #
Why can we convert between chars and ints?
Because chars are actually number values that correspond to symbols per ASCII
What is one thing that marks the limit of scope in C?
Curly braces.
Any variable declared inside a set of curly braces does not exist outside the curly braces.
How is a global variable declared in C?
It is declared before the main() function.
Why can you access an individual character within a string?
Because strings are implemented in the CS50 library are actually arrays of chars.
How do you access a certain element of a string?
stringName[i]; where i is the index of the character you want to access.
Counting starts at 0.
Where is a user made function declared?
Above main(), if it will be used in main().
What is the sentinel value that GetString() returns when the function fails to get a string?
NULL
How do you declare multiple variables in one line?
int a = 0, b = 1 …
What C library contains functions that classify and transform individual characters?
ctype.h
When are curly braces not needed for if-else blocks?
When the following code is only one line.
How do you access the man pages?
type “man functionName”