# Few C++ Expressions

1. What is the value of the expression
(x OR y) AND z
if x = true, y = false and z = false?

2. What is the final value of y after executing the following code:

int y = 0;
int x = 1;
while(x<5)
{
y = y + 2*x;
x = x+1;
}

3. Write the code above using a repeat loop.

4. Write the code above using a for loop.

5. What is the final value of x after executing the following code:

int x = 10
if (x>10)
{
x = x * 3;
}
else
{
x = 2*x;
}

6. If x = 2 and y = 3 what are the values of the following expressions?
a. (x + y * 2)/4 + 4
b. (y - x) * 3 + (x + y) * 2

7. How many times does the following loop execute?
int x = 8;
do
{
cout<<"this is a message"<<endl;
x--;
}while(x!=0);

8. What is the output of the following code? Show your work with each of the 3 variables.

int x = 0;
int y = 1;
int total = 0;
while(x<=3)
{
y = y+x;
total = total + y;
x = x+1;
}
cout<<"Total is "<<total<<endl;

9. What C++ statement would you use to print the phrase "CMIS102A" three times in a new line?