Chapter 13

Ace your homework & exams now with Quizwiz!

Which of the following statements is correct?

#define X 3

A macro commonly defined in the stdio.h header file is

#define getchar() getc(stdin)

The __________ directive prints out a message.

#error

Symbolic constants and macros can be discarded by using the __________ preprocessor directive.

#undef

The preprocessor directive #error 7 - Out of range error - contains __________ tokens.

7

Which statement is false?

Arithmetic expressions cannot be evaluated in preprocessor directives

Which statement is correct?

Expressions with side effects (i.e., variable values are modified. should not be passed to a macro because macro arguments may be evaluated more than once. Answers:

Given the preprocessor directive #define HAPPY(x) printf ("Happy, " #x "\n"); How would you invoke this macro to generate a statement that would print Happy BIRTHDAY (followed by a newline)

Happy(Birthday)

Which line has the most tokens?

I like C + +.

Which statement is false?

If NDEBUG is defined, only the next assertion is ignored.

Which statement about the #include directive is false?

If the file name is enclosed in angle brackets, the preprocessor searches in the same directory as the file being compiled for the file to be included.

Which statement about the preprocessor is false?

If the macro

Which statement about macros is true?

Macro arguments should be enclosed in parentheses in the replacement text.

Which symbolic constant must be defined to ignore all assert statements?

NDEBUG

What does the following preprocessor code do? #if !defined(NULL) #define NULL 0 #endif

The code defines NULL to be 0 only if NULL is undefined

Which statement about "commenting out" code is false?

The following preprocessor code effectively comments out code #if 1 code prevented from compiling #endif

Which statement about symbolic constants and/or macros is true?

The scope of a symbolic constant or macro is normally from its point of definition to the end of the file, but this can be modified with a preprocessor directive.

What is a problem with the preprocessor statement: #define PI 3.14159;

The semicolon is part of the substitution text, so 3.14159; will be substituted whereever PI is used and this could lead to syntax errors.

Which statement about symbolic constants is true?

Using meaningful names for symbolic constants helps make programs more self-documenting.

A single, conditionally compiled printf statement may be inserted in a program anywhere the C compiler expects a single statement.

Which statement about conditional compilation is false?

Which of the following is not a predefined symbolic constant?

__ERROR__

Which statement about predefined symbolic constants is false?

__LINE__ is used to specify the range of line numbers in the source file. Answers:

The # preprocessor operator causes a replacement text token to be converted to

a string surrounded by quotes

The # operator causes __________ to be converted to a __________.

a text token, string surrounded by quotes.

Which statement about the preprocessor is false?

all preprocessor directives must end in a semicolon

The #undef preprocessor directive

allows macros to be redefined with #define later in the program.

Preprocessing occurs

before a program is compiled.

Which is a correct form of the #include directive

c. #include <filename>

Macros

can help avoid the overhead of a function call.

The #include preprocessor directive causes a(n) ____________ to be included in place of the directive.

copy of a file

Macros are defined

in a #define preprocessor directive

A pragma not recognized by the implementation

is ignored

Which of the following is false? Macros

must be defined with arguments.

Every #if construct

must end with #endif.

Conditional compilation cannot be used to

perform loops.

The #error directive #error tokens

prints an implementation-defined message including the tokens specified in the directive

f the macro #define RECTANGLE_AREA(x, y) ((x) * (y)) has been defined. Then the line rectArea = RECTANGLE_AREA(a + 4, b + 7); will be expanded to

rectArea = ((a + 4) * (b + 7));

The preprocessor directive #line 200

starts line numbering from 200 beginning with the next source-code line

To customize preprocessing to the unique needs of a particular installation, you would most likely use the __________ directive.

#pragma

const variables are preferred to symbolic constants (from #define) because

const variable names are visible to the compiler

Which is not a capability of the preprocessor?

definition of functions

Preprocessor directives

do not end in a semicolon.

A(n) unsafe macro is one that ________.

evaluates its argument(s) more than once

he #include directive

includes a file in the program before compilation

Macros have the disadvantage, when compared to functions, of

increasing program size (if the macros are called from many places in the program).

Which include statement is usually appropriate for user-defined files?

#include "filename"

Which statement about the #include preprocessor directive is false?

It includes standard library header files such as standardio.h.

Which of the following is not a valid directive?

#for

Large portions of code can be prevented from compiling by

#if 0 code prevented from compiling #endif

A shorthand for #if !defined is

#ifndef

The preprocessor directive #pragma tokens

causes an implementation-defined action.

The statement #line 250

causes the compiler to renumber the lines from 250 beginning with the next source code line.

Operator ##

concatenates two tokens in a macro definition

Which statement about the following assertion is true? assert(count <= 7);

It evaluates its argument at execution time.

Which statement is false?

Symbolic constants may be redefined with new values.

The parentheses around the two rightmost occurrences of x in the following preprocessor directive: #define CIRCLE_AREA(x) ((PI) * (x) * (x))

are included to eliminate bugs when an expression is substituted for x.


Related study sets

Egan's Chapter 39: humidity and bland aerosol therapy

View Set

Ch. 1: Understanding Medical Word Elements: Learning Activity 1-1

View Set

Section 5: Generational Differences

View Set

311L module 2 (CP quizzes & rationales)

View Set