ECE-1011 (SPRING 2003)

QUIZ #3 PREP SHEET

NOTE: Some of these questions ask you to think beyond the strict information given in the text.

(p98) The "top-down" design approach can also be refered to as what type of strategy?

(p98) How far - how detailed - should the problem decomposition be carried?

(p99) What are two of the tools that are used to help determine the order of steps to solve a problem?

(p100) What are the three basic control structures used in structured programming?

(p103) Why should alternative solutions be considered?

(p103) Why shouldn't a program generally be written to catch every possible error condition that could occur?

(p104) What is a "program walkthrough"?

(p105) Two operators are "complementary" if they always produce the opposite result. With that in mind, group the six relational operators available in C into three pairs of complementary operators.

(p105) Why does C, unlike many languages, use a different operator for equality (= = ) than it does for assignment (=)?

(p106) Write a C statement that implements C = A xor B such that C is true only if one of either A or B is true (not both). The truth table for such a function is as follows:

A B A xor B
FALSE FALSE FALSE
FALSE TRUE TRUE
TRUE FALSE TRUE
TRUE TRUE FALSE

(p107) One attempt to implement the XOR function between A and B is C =  A !! B    &&   !A && B. Why won't this work?

(p108) If the integer variable "a" is set equal to 13 earlier in the code, what will happen with the following statement if(a = 0) printf("a is equal to zero\n") else printf("a is not zero\n")? What is the variable "a" equal to after this code has executed?

(p108) What is the output of the following code segment? All variables are declared as integers.

a = 15;

b = 20;

if( a >= b )

   a = 50;

   b = 100;

printf("a = %i, b = %i\n", a, b);

(p112) What common mathematical function does the conditional statement a = (a<0)? -a : a; implement?  

(p114) In a switch statement, the case labels must be unique constants. This implies two conditions that must be met. What are they?

(p115) Draw the flow charts for each of the three looping structures available in C.

(p116) What is the difference between a while() loop and a do..while() loop?

(p117) It is claimed that any code written using one type of looping structure can be written using either of the two other structures. Is this a true statement? Justify your answer. If it is a true statement, then what is the advantage of having three different structures available if any on of them is sufficient?