Explore BrainMass

# output of the following C++ code

Not what you're looking for? Search our solutions OR ask your own Custom question.

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

1. What is the output of the following C++ code?

num = 1;
while (num < 10)
{
cout << num << " ";
num = num + 2;
}
cout << endl;

2. Suppose that the input is 38 45 71 4 -1. What is the output of the following code? Assume all variables are properly declared.

cin >> sum;
cin >> num;
while (num != -1)
{
sum = sum + num;
cin >> num;
}
cout << "Sum = " << sum << endl;

3. Write a for statement to add all the multiples of 3 between 1 and 100.

https://brainmass.com/computer-science/control-structures/output-following-code-32511

#### Solution Preview

1. What is the output of the following C++ code?

num = 1;
while (num < 10)
{
cout << num << " ";
num = num + 2;
}
cout << ...

#### Solution Summary

The output of the following C++ code is determined.

\$2.49