emilyrivera2002 emilyrivera2002
  • 21-09-2021
  • Computers and Technology
contestada

4. What is the output of the following C++ code?
int num = 1;
while (num * num <= 50)
{
cout << num << " ";
num = num + 2;
}
cout << endl;

Respuesta :

Аноним Аноним
  • 21-09-2021

Answer:

3 5 7 9

Explanation:

First, integer 1 is stored in variable num.

In the while statement, the condition is 1*1 <=50 (Which is true)

If that condition is met, we add 2 to variable num, resulting in 3.

The condition fails at 8 because 8*8 is 64, but the condition is met at 7*7 which is 49 and then we add 2 in variable num, resulting in 9.

Answer Link

Otras preguntas

28. Referrals for mental health services should be made when A. the problems have persisted for several weeks to months. B. the situation is steadily improving.
Please help? I have placed the screenshot below.
the court case plessy v. ferguson challenged the legality ofA. racially segregated facilitiesB. scare tactics to enforce Jim Crow LawsC. racially segregated hou
Melinda is hauling water in her pickup truck .an old bridge has a maximum weight limit of 6,000 pounds. to find the weight of her truck ,Melinda uses the expres
An 8-foot piece of rope is cut into sections that are 8 3 83 feet long. How many sections of rope are there?
Round 6.28 from the tenths place
What continents does the equator pass through?
How many babies are born each year in the us?
what is the value of x
The weight of an object is the product of its mass, m, and the acceleration of gravity, g (where g=9.8 m/s2). If an object’s mass is m=10. kg, what is its weigh