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

Humans, monkeys, and apes belong to a group of animals known as
What's 32xy divided by 24yz and how do you figure it out.  The question also asks me to write it as a fraction then cancel (or reduce).
what is 6/10 as a terminating decimal?
5 FRIENDS GO OUT TO LUNCH AND ORDER 5 PIZZAS, THE FRIENDS DIVIDED THE PIZZAS EVENLY.FIND HOW MUCH PIZZA EACH FRIEND GOT AS A DECIMAL
write 6/10 as a terminating decimal
Humans, monkeys, and apes belong to a group of animals known as
An athlete runs 90 laps in 6 hours. This is the same as how many laps per minute? (A) 1/15 (B) 1/9 (C) 1/4 (D) 1/2 (E) 1
simplify: -3(4×-4) 7x(3+4)
What is 3,649x7 in distributive property form?
Please help I don't know what to do for number 40