UMBC CS 104
UMBC CMSC 104 * CSEE | 104 | current 104

CMSC 104, Section 105

Problems Evaluating Math Equations


1.) Given the equation y = ax3 + 7 ,which of the following, if any, are correct C statements for this equation? We can chose values for the variables of a and x. For example: a=3 , x=2 and find the value of y.

a.) y = a * x * x * x + 7;

b.) y = a * x * x * (x + 7);

c.) y = (a * x) * x * (x + 7);

d.) y = (a * x) * x * x + 7;

e.) y = a * ( x * x * x ) + 7;


2.) State the order of evaluation of the operators in each of the following C statements, and show the value of x after each statement is performed.

a.) x = 7 + 3 * 6 / 2 - 1;

b.) x = 2 % 2 + 2 * 2 - 2 / 2;

c.) x = (3 * 9 * (3 + (9 * 3 / ( 3 ) ) ) ) ;