Explore BrainMass

Few C++ Expressions

This content was STOLEN from BrainMass.com - View the original, and get the already-completed solution here!

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;
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;
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;
cout<<"this is a message"<<endl;


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;
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?


10. How many times in the following C++ code will "CMIS 102" be written to the standard output?

for (int i = 1; i<=3; i++)
for( int j = 1; j<=i; j++)
cout <<"CMIS 102"<<endl;

© BrainMass Inc. brainmass.com October 24, 2018, 7:47 pm ad1c9bdddf

Solution Summary

This posting contains some logic expressions and some C++ Statements.

See Also This Related BrainMass Solution

Programming languages type less

1. Some programming languages are typeless. What are a few of the obvious advantages and disadvantages of having no types in a language. Keep your answer to 1 paragraph or less.
2. Dynamic type binding is closely related to implicit heap-dynamic variables. Explain this relationship. Keep your answer to 1 paragraph or less.
3. What significant justification is there for the -> operator in C and C++?
4. What are the arguments for and against Java's implicit heap storage recovery, when compared with the explicit heap storage recovery required in C++? Consider real-time systems.

View Full Posting Details