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

Corey, a supervisor, needs to rate the performance of 20 subordinates. He uses a rating scale to rate them on a scale of 1 to 10. He rates 18 employees at 5, wh
What do thunderstorms and winter storms have in common?
Write a one-page formal business letter to Simon D'Azure, a retired worker, that he will have to pay half the costs of his health care premiums directly. You wi
which statement expresses the theme of the drama fourteen alice
Based on the chart,which area would have been most likely to be affected by the slave trade?
What does regulating individual freedom mean?
What stance does Davis take on war beginning? That if the Confederates fight, they know that history will agree it was necessary That the only way war will star
1/2(4n-8)+10=4(n+5)​
Android Products, Inc., agreed to accept a $1,000, one-year, 10 percent note from C. Mate. On its maturity date of December 16, Mate honors the note by making a
2. How can understanding geology help us survive?