Hhh Flashcards
(19 cards)
What operator is used to pass values to scanf?
& operator
What does the specifier %d do in scanf?
Reads an integer
What does the specifier %f do in scanf?
Reads a float
What is the purpose of the %c specifier in printf?
Reads a character
What does the %s specifier do in printf?
Reads a string
Fill in the blank: To read an integer, use scanf with the format specifier _______.
%d
Fill in the blank: To read a float, use scanf with the format specifier _______.
%f
Fill in the blank: The command to read a single-word input is scanf(“%s”, _______);
name
What is the purpose of escape sequences?
Used for formatting the output
What is the escape sequence format?
Backslash followed by a letter
What does the command printf(“Name: %s\n”, name) do?
Prints the name followed by a new line
What does the command scanf(“%c”, &grade) do?
Reads a character input for grade
True or False: The command scanf(“%s”, name) reads multi-word input.
False
What is the significance of the space before %c in scanf(“ %c”, &grade)?
It consumes the newline character
What does the command printf(“Age: %d\n”, age) do?
Prints the age as an integer followed by a new line
What type of variable is used to store a person’s name in the example?
char name[50]
What is the return type of the main function in C?
int
What is the purpose of the return 0 statement in the main function?
Indicates successful completion of the program
Fill in the blank: To read a height variable as a float, use scanf(“%f”, &______);
height