Question

In: Computer Science

construct the trace table or trace table list for the function call CR (111) where the...

construct the trace table or trace table list for the function call CR (111) where the definition of CR () is
bool CR ( int n )
{
bool w,x,y,z,r;
int c;
c= 3*n;
c + = 16;
c=c%5;
w=c==4;

Solutions

Expert Solution

Trace Table

n c w
111 - -
111 333 -
111 349 -
111 4 -
111 4 4

Explaination:

The value given to us is CR(111) that means the initial value of n is 111. The variables that we need to add in the Trace Table are n, c and w as these are the only variables that are used in this set of code.

In the first step we need to check the initial values of all the 3 variables and make an entry in the first row accordingly. the initial value of n is 111 and for c & w we don't have any value so we are simply putting "-".

In the 5th line of the code the value of c is changed to 333 as it says c=3*n i.e. c=3*111 which is 333 so the 2nd row in the trace table is filled as n 111 (as the value of n is not changed) , c 333 and we don't have any value for w yet so "-".

Now, in the 6th line of the code the value of c is changed to 349 as it says c+=16 i.e. c=333+16 which is 349 so the 3rd row of the trace table is filled as n 111 (no change) , c 349 and w "-".

In the 7th line of the code, the value of c is changed to 4 as it says c=c%5 i.e. c=349%5 which is 4 (% modulus operator gives the remainder of 2 numbers); so the 4th row is filled as n 111(no change) , c 4 and w "-".

In the last line of the code, we are assigning the value of c to w if the value of c is 4 which is true so the last row of the trace table is filled as n 111 (no change yet) , c 4 and w also 4.

I hope I made the solution clear enough to understand!!


Related Solutions

1) Construct a table to list the six factors affecting option value (including call and put...
1) Construct a table to list the six factors affecting option value (including call and put option) and their relation (positive or negative) with option value 2) Explain why the six factors positively or negatively affect option value (Hint: Address the difference between intrinsic value and the time value of the option)
Q2) (a) construct a truth table for the following function: ?(?, ?, ?) = (?? +...
Q2) (a) construct a truth table for the following function: ?(?, ?, ?) = (?? + ?̅?) ̅̅̅ + ?? (b) Use the truth table of (a) to write the function F in sum of minterms form. (c) Expand the function ?(?, ?, ?) = ? + ?̅? to product of Maxterms form. (d) Simplify the following function using K-Map. ?(?, , ?, ?, ?) = ?̅? + ?? + ?̅? + ??̅?
Account# 111 - Cash Date Description Debits Credits Balance   Beginning Balance $0.00 CR 9/01/2015   CR 1...
Account# 111 - Cash Date Description Debits Credits Balance   Beginning Balance $0.00 CR 9/01/2015   CR 1 owner's investment $21,000.00 $21,000.00 DR 9/02/2015   Race Car Purchase $13,500.00 $7,500.00 DR 9/03/2015   Track Rent $4,185.00 $3,315.00 DR 9/04/2015   Newpaper Advertising $251.19 $3,063.81 DR 9/06/2015   Cash Collected $1,200.00 $4,263.81 DR 9/07/2015   Service Provided $2,000.00 $6,263.81 DR 9/07/2015   Payment on Sep. 6 $450.00 $5,813.81 DR 9/09/2015   Sept. Advertising $325.68 $5,488.13 DR 9/11/2015   Payment on Sep. 3 $1,100.00 $4,388.13 DR 9/11/2015   (AR Collection) $400.00 $4,788.13 DR...
Dudley has a utility function U(C, R) = CR, where R is leisure and C is...
Dudley has a utility function U(C, R) = CR, where R is leisure and C is consumption per day. He has 16 hours per day to divide between work and leisure. Dudley has a non-labor income of $48 per day. (a) If Dudley is paid a wage of $6 per hour, how many hours of leisure will he choose per day? (b) As a result of a promotion, Dudley is now paid $ 8 per hour. How will his leisure...
Dudley has a utility function U(C, R) = CR, where R is leisure and C is...
Dudley has a utility function U(C, R) = CR, where R is leisure and C is consumption per day. He has 16 hours per day to divide between work and leisure. Dudley has a non-labor income of $48 per day. (a) If Dudley is paid a wage of $6 per hour, how many hours of leisure will he choose per day? (b) As a result of a promotion, Dudley is now paid $ 8 per hour. How will his leisure...
USING PYTHON Write a program to create a number list. It will call a function to...
USING PYTHON Write a program to create a number list. It will call a function to calculate the average values in the list. Define main ():                        Declare variables and initialize them                        Create a list containing numbers (int/float)                        Call get_avg function that will return the calculated average values in the list.                                       Use a for loop to loop through the values in the list and calculate avg                        End main()
Construct a table that illustrates the structure and function of the glycocalyx, ECM, 3 types of...
Construct a table that illustrates the structure and function of the glycocalyx, ECM, 3 types of cytoskeletal elements, and the 3 types of cell-cell junctions. In the table include the specific macromolecules that make up these structures, specific properties these structures give to the cell or tissue. Give one example of a tissue or cell whose properties depend on each of these structures.
Trace the pathway of urine. From where it is produced to where it is released. Where...
Trace the pathway of urine. From where it is produced to where it is released. Where do the nitrogenous wastes come from? Think of macromolecules How does the liver detoxify ammonia? What is the functional unit of the urinary system?
Write a function child_indices(parent, branch_factor) that returns a list containing the list of indices where the...
Write a function child_indices(parent, branch_factor) that returns a list containing the list of indices where the children of the node at index parent will be stored for a heap list with the given branch_factor (ie, a branch_factor-heap). Python language Notes: The function should return all possible indices and the indices should be in order from smallest to biggest. The values in the heap list start at index 1 - that is the root of the heap is at index 1...
Trace the path of cerebrospinal fluid from where it is formed to where it is reabsorbed...
Trace the path of cerebrospinal fluid from where it is formed to where it is reabsorbed back into the blood. Match each function with the appropriate area of the brain. A. Basal nucleus                     C. Hypothalamus                    E. Precentral gyrus          G. Superior colliculus B. Cerebellum                                     D. Inferior colliculus             F, Postcentral gyrus    H. Insula ______ Primary sensory area. ______ Suppress unwanted motor activity. ______ Involved in auditory reflexes. ______ Controls some endocrine functions. How do the dural...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT