Hh Flashcards
(14 cards)
What is the format specifier for an integer in C?
%d
What is the format specifier for a float in C?
%f
What is the format specifier for a character in C?
%c
What is the format specifier for a string in C?
%s
What is the output of printf(“%d”, 10)?
10
What is the output of printf(“%0.2f”, 3.14)?
3.14
What is the output of printf(“%c”, ‘A’)?
A
What is the output of printf(“%s”, “Hello”)?
Hello
What is the purpose of the scanf function?
To take input from the user
What is the syntax for the scanf function?
scanf(“format string”, &variable1, &variable2, …);
What does the format string in scanf specify?
The type of input expected
What is the role of the & operator in scanf?
To pass the variable’s address (except for strings)
Fill in the blank: The format specifier for a float is _______.
%f
True or False: The scanf function can take input without the & operator for strings.
True