CS50 Week 1 Flashcards

0
Q

What is the Linux command to show the content of a directory?

A

ls

Stands for list

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
1
Q

The format of an if condition

A
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");
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the Linux command to create a new folder?

A

mkdir

Make directory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the Linux command to change the directory?

A

cd

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the Linux command to delete a file?

A

rm

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the Linux command to delete a directory?

A

rmdir

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What indicates a new line?

A

\n

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the format of a while loop?

A

while ()
{
printf(“blah\n”)
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What function will get a string?

A

GetString()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

A line that starts with # is what?

A

A preprocessor directive

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is the symbol for the boolean operator “or”?

A

||

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is the symbol for the boolean operator “and”?

A

&&

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the syntax for a switch?

A
switch (x)
{
    case 1:
        // do this
        break;
    case 2:
        // do that
        break;
    default:
        // do this other thing
        break;
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is the syntax of a for loop?

A
for (initializations; condition; updates)
{
    // do this again and again
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is the syntax for a while loop?

A

while (true) {
print(“hello, world\n”);
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is the syntax for a do/while loop

A
do
{
    // do this again and again
}
while (condition);
17
Q

How do we get a character from the user?

A

GetChar

18
Q

How do we get a double from the user?

A

GetDouble

19
Q

How do we get a float from the user?

A

GetFloat

20
Q

How do we get an int from the user?

A

GetInt

21
Q

How do we get a longlong from the user?

A

GetLongLong

22
Q

What data types does C not contain natively?

A

bool

string

23
Q

What are the types of C variables?

A
char
float
double
int
long long
24
Q

What is the printf formatting character for char?

A

%c

25
Q

What is the printf formatting character for an int?

A

%i

or %d

26
Q

What is the printf formatting character for a float?

A

%f

27
Q

What is the printf formatting character for a long long?

A

%lld

28
Q

What is the printf formatting character for a string?

A

%s

29
Q

What is the escape sequence for newline?

A

\n

30
Q

What is the escape sequence for carriage return?

A

\r

31
Q

What is the escape sequence for a single quote?

A

'

32
Q

What is the escape sequence for a double quote?

A

"

33
Q

What is the escape sequence for a backslash?

A

\

34
Q

What is the escape sequence for a null terminator?

A

\0