CS50 Week 1 Flashcards
What is the Linux command to show the content of a directory?
ls
Stands for list
The format of an if condition
if (x > y) { printf("x is less than y\n"); } else if (x > y) { printf("x is greater than y\n"); } else { printf("x is equal to y\n");
What is the Linux command to create a new folder?
mkdir
Make directory
What is the Linux command to change the directory?
cd
What is the Linux command to delete a file?
rm
What is the Linux command to delete a directory?
rmdir
What indicates a new line?
\n
What is the format of a while loop?
while ()
{
printf(“blah\n”)
}
What function will get a string?
GetString()
A line that starts with # is what?
A preprocessor directive
What is the symbol for the boolean operator “or”?
||
What is the symbol for the boolean operator “and”?
&&
What is the syntax for a switch?
switch (x) { case 1: // do this break;
case 2: // do that break;
default: // do this other thing break; }
What is the syntax of a for loop?
for (initializations; condition; updates) { // do this again and again }
What is the syntax for a while loop?
while (true) {
print(“hello, world\n”);
}
What is the syntax for a do/while loop
do { // do this again and again } while (condition);
How do we get a character from the user?
GetChar
How do we get a double from the user?
GetDouble
How do we get a float from the user?
GetFloat
How do we get an int from the user?
GetInt
How do we get a longlong from the user?
GetLongLong
What data types does C not contain natively?
bool
string
What are the types of C variables?
char float double int long long
What is the printf formatting character for char?
%c
What is the printf formatting character for an int?
%i
or %d
What is the printf formatting character for a float?
%f
What is the printf formatting character for a long long?
%lld
What is the printf formatting character for a string?
%s
What is the escape sequence for newline?
\n
What is the escape sequence for carriage return?
\r
What is the escape sequence for a single quote?
'
What is the escape sequence for a double quote?
"
What is the escape sequence for a backslash?
\
What is the escape sequence for a null terminator?
\0