Hhh Flashcards

(19 cards)

1
Q

What operator is used to pass values to scanf?

A

& operator

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

What does the specifier %d do in scanf?

A

Reads an integer

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

What does the specifier %f do in scanf?

A

Reads a float

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

What is the purpose of the %c specifier in printf?

A

Reads a character

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

What does the %s specifier do in printf?

A

Reads a string

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

Fill in the blank: To read an integer, use scanf with the format specifier _______.

A

%d

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

Fill in the blank: To read a float, use scanf with the format specifier _______.

A

%f

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

Fill in the blank: The command to read a single-word input is scanf(“%s”, _______);

A

name

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

What is the purpose of escape sequences?

A

Used for formatting the output

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

What is the escape sequence format?

A

Backslash followed by a letter

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

What does the command printf(“Name: %s\n”, name) do?

A

Prints the name followed by a new line

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

What does the command scanf(“%c”, &grade) do?

A

Reads a character input for grade

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

True or False: The command scanf(“%s”, name) reads multi-word input.

A

False

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

What is the significance of the space before %c in scanf(“ %c”, &grade)?

A

It consumes the newline character

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

What does the command printf(“Age: %d\n”, age) do?

A

Prints the age as an integer followed by a new line

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

What type of variable is used to store a person’s name in the example?

A

char name[50]

17
Q

What is the return type of the main function in C?

18
Q

What is the purpose of the return 0 statement in the main function?

A

Indicates successful completion of the program

19
Q

Fill in the blank: To read a height variable as a float, use scanf(“%f”, &______);