Purchase Solution

Few C++ Expressions

Not what you're looking for?

Ask Custom Question

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

Answer:

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

Answer:

3. Write the code above using a repeat loop.

Answer:

4. Write the code above using a for loop.

Answer:

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

Answer:

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

Answer:

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

Answer:

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;

Answer:

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

Answer:

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;

Purchase this Solution

Solution Summary

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

Purchase this Solution


Free BrainMass Quizzes
Word 2010: Table of Contents

Ever wondered where a Table of Contents in a Word document comes from? Maybe you need a refresher on the topic? This quiz will remind you of the keywords and options used when working with a T.O.C. in Word 2010.

Inserting and deleting in a linked list

This quiz tests your understanding of how to insert and delete elements in a linked list. Understanding of the use of linked lists, and the related performance aspects, is an important fundamental skill of computer science data structures.

C# variables and classes

This quiz contains questions about C# classes and variables.

C++ Operators

This quiz tests a student's knowledge about C++ operators.

Basic UNIX commands

Use this quiz to check your knowledge of a few common UNIX commands. The quiz covers some of the most essential UNIX commands and their basic usage. If you can pass this quiz then you are clearly on your way to becoming an effective UNIX command line user.