An assertion

a. is never more than just comment embedded in code
b. are always easily and precisely stated with C++ syntax,
c. is used to document and check correctness in programs
d. is typically a precondition or postcondition for a function
e. if converted to a Boolean statement, may be used with the library assert macro to test whether the assertion is satisfied at that point in the code.


All of these except a) and b) are true.
Explanation: a) is way too restrictive. b) is optimistic beyond dreams. An assertion may well be just a comment, but can be much more, as c)-e) state. Assertions are used like this: If you know that some of variables in your program should have a specific values, or these variable should make an expression take on a value you know, you can write this out as a Boolean expression (as an assertion) and test it.

Computer Science & Information Technology

You might also like to view...

Analyze the following code.

``` #include using namespace std; int main() { char *p; cout << "Enter a string: "; cin >> p; cout << p << endl; return 0; } ``` a. If you run the program and enter abc, unpredictable characters will be displayed. b. If you run the program and enter abc, abc will be displayed. c. If you run the program and enter abc, nothing will be displayed. The program runs without errors. d. If you run the program and enter abc, a runtime error will occur, because p is used without being initialized.

Computer Science & Information Technology

Find a Web page that’s a “wall of words” (long paragraphs with little or no formatting) and reformat it so that it supports scanning.

What will be an ideal response?

Computer Science & Information Technology

Answer the following statement(s) true (T) or false (F)

1. The C++ operator * means “the address of”. 2. For each array created, the array name becomes the name of the pointer constant the compiler creates for the array. 3. As each variable is defined in a program, sufficient storage for it is assigned from a pool of computer memory locations made available to the compiler. 4. The delete operator alters the address passed to it. 5. Addresses cannot be incremented or decremented.

Computer Science & Information Technology

When the Pushpin icon on the Auto Hide button is vertical, the part of the Visual Studio window shown in the accompanying figure is said to be in ____________________ mode.

Fill in the blank(s) with the appropriate word(s).

Computer Science & Information Technology