Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.
Trending News
what are the out come for these C++ programming problems?
1. What value is assigned to fee by the if statement when speed is 8?
if (speed < 35)
fee = 10;
else if (speed < 25)
fee = 30;
else if (speed <10)
fee = 50;
2. What does the following statement print if i has the value 20? What does it print if i has the value -20?
cout << i >= 0 ? i : -i << endl;
3. What output does the following program fragment produce?
int i = 1;
while (i <= 128)
{
cout << i << “\t”;
i *= 3;
}
4. What output does the following program fragment produce?
int y, x = 1, total = 0;
while (x < 10)
{
y =x + x;
cout << y << endl;
total += y;
++x;
}
cout << “Total is ”<< total << endl;
1 Answer
- husoskiLv 78 years agoFavorite Answer
There is nothing complicated here. Try putting each into a main() function and running it to see if reality matches your pencil and paper answer. If it doesn't, and you've double-checked the code, then you have something very basic to learn about C++.
Hint for #1: The conditions in an if/else if/else ladder are tested in order, but only up to the first "true" result. The statement or block associated with that condition is executed and no other conditions are even evaluated. Is 8 less than 35? What does that tell you about the first if condition?