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

What is farm management ​
(e) The women on the Maryland field hockey team are not a random sample of all female college field hockey players. Similarly, the women on the Maryland basketb
a rectangle. one side is 2x + 7 and the other is x+3 The perimeter of the rectangle is P Find a formula for P in terms of x x
Say what people were doing when the wether changed
Michel took 2 5/8 hours to clean the bathroom. He took 4 3/4 hours to clean the bedroom. How much longer did it take Micheal to clean the bedroom?
A merchant bought 1000 electric bulbs at the rate of Rs.150 each. 50 of them were broken on the way and the remaining he sold at the profit of 5%.What was the s
What are 4 mutations?
PLEASE answer my question correctly6 to 10​
Where would sound NOT be able to travel? A. through the ground B. through the ocean C. through the air D. through outer space
If $300 is invested at a rate of 5% per year and is compounded quarterly how much will the investment be worth in 15 years?