Chapter 2: Introduction to the C Language
What are the types of format with printf command?
% Flag Width Precision Size Code
What is a logic error?
-program will compile and run but not do what you intended
T/F: Any valid printable ASCII character can be used in an identifier.
False
T/F: For defined constants, end the declaration with a semi-colon
False
T/F: The C standard function that receives data from the keyboard is printf.
False
T/F: The purpose of a header file, such as stdio.h, is to store a program's source code.
False
What are the three ways constants can be coded?
Literals Define commands Memory constants
What are the three floating point types?
Real number (float, double, long double) Imaginary (float imaginary, double imaginary, long double imaginary) Complex (float complex, double complex, long double complex)
T/F: Only one of the functions in a C program must be called main.
True
Which of the following is not a character constant in C? a. 'C' b. 'bb' c. "C" d. '?' e. ' '
b. 'bb' c. "C"
The _______ conversion specification is used to read or write a short integer. a. %c b. %d c. %f d. %hd e. %lf
d. %hd
Which of the following is not a data type? a. char b. float c. int d. logical e. void
d. logical
The _________ function reads data from the keyboard. a. displayf b. printf c. read d. scanf e. write
d. scanf
Which of the following identifiers is not valid? a. _option b. amount c. sales_amount d. salesAmount e. $salesAmount
e. $salesAmount
What is an identifier?
sequence of characters used for naming variables, functions and preprocessor macros
What is an example of preprocessor directives?
stdio.h, math.h, stdlib.h
What is a run-time error?
-unexpected termination of program while it is running -cannot be predicted by the compiler -dividing by 0 segmentation fault
What are the three integral types?
Boolean (true and false) Character Integer (sizes: short int, int, long int, long long int
What is every C program consist of?
Declarations, definitions and one or more statements
To print data left justified, you would use a __________ in the conversion specification. a. flag b. precision c. size d. width e. width and precision
a. flag
Which of the following statements about block commends is false? a. Comments are internal documentation for programmers b. Comments are used by the preprocessor to help format the program c. Commends begin with a /* token d. Comments cannot be nested e. Comments end with a */ token
b. Comments are used by the preprocessor to help format the program
Which of the following statements about the structure of a C program is false? a. A C program starts with a global declaration section b. Declarations sections must have at least one function c. Every program must have at least one function d. One and only one function may be named main e. Within each function there is a local declaration section
b. Declarations sections must have at least one function
What is the address operator? a. The address modifier (@) in the conversion specification b. The ampersand (&) c. The caret (^) d. The percent (%) e. The pound sign (#)
b. The ampersand (&)
Which of the following is not an integer constant in C? a. -320 b. +45 c. -31.80 d. 1456 e. 40
c. -31.80 d. 1456 e. 40
Which of the following statements about a constant is true? a. Character constants are coded using double quotes b. It is impossible to tell the computer that a constant should be a float or a long double c. Like variables, constants have a type and may be named d. Only integer values can be used in a constant e. The value of a constant may be changed during a program's execution
c. Like variables, constants have a type and may be named
The code that establishes the original value for a variable is known as a(n): a. assignment b. constant c. initializer d. originator e. value
c. initializer