LillySchool5325 LillySchool5325
  • 22-08-2019
  • Computers and Technology
contestada

How would you print from 1 to 1000

Respuesta :

ExieFansler ExieFansler
  • 27-08-2019

Answer:

There are two ways to print 1 to 1000

  1. Using Loops.
  2. Using Recursion.

Explanation:

Using loops

for(int i=1;i<=1000;i++)

{

  cout<<i<<" ";

}

Using recursion

Remember you can implement recursion using a function only.

void print(int n)

{

  if(n==0)

  return;

  print(n-1);

  cout<<n<<" "';

}

you should pass 1000 as an argument to the function print.

Answer Link

Otras preguntas

How is humor used in this excerpt to effectively critique marriage
Why did James first resist parliaments grown power
What impact did Emperor Constantine's establishment of the "New Rome" (Constantinople) have on the Roman Empire? a. the expense of building the new city impovri
A rectangular block has dimensions 2.9 cm x 3.5 cm x 10.0 cm. the mass of the block is 615.0 g. what is the volume and density of the block? (answer it with cor
what image of hatred is created by the personification
How is a mixture different from a compound? 1. composition of a mixture may be constant. 2. components of a mixture can be separated by physical means. 3. compo
Can u help me ok the first one plz
"the nervous blue flash in his eyes. . . ." Which poetic technique does Shapiro use in this line?
Dorothy works as a medicinal chemist in a pharmaceutical company. What could one of her assignments be
The equation y = −2x + 3 is the boundary line for the inequality y ≤ −2x + 3. Which sentence describes the graph of the inequality?