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

How did the way in which European colonialists carved up Africa in the 1800s lead to civil strife in many new African nations?
What always affects measurement error in an experiment?
A photographer’s camera sits on a tripod that is 1.8 m above the ground. The base of the tripod is 44 m from the base of a tree. The photographer spots a woodp
Is nigel farage left handed?
What Are The Main Complaints And Demand Of The People In The Non Democratic Country?
the right to petition members of the government is contained in the blank amendment to the constitution.
so a 4 digit number is represented ABCD, they are not multiplied together, each letter represents 1 single , whole number if ABCD times D=DCBA solve for the va
changes to the earth that can be explained by plate tectonics include all the following except ___ Earthquakes,erosion,mountain ranges, volcanoes
how does a stratovolcano form
Why did trade and travel decline after the fall of Rome?