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 the solution for this inequality -10x <40
Why are the irish famous for drinking?
what is 0.000702 in scientific notation.
if 9^x-9^x-1=24, then find the value of (6x)^x
container is 5 meters wide ,6meters long and 3 meters in depth what is the capacity in quarts
In what types of environments would you find protists?
Measurement is the use of numbers according to a standard. True or False
Why are the irish famous for drinking?
Find the slope of the line that passes through each pair of points
solve using the substitution and elimination method 3a-12b=9 4a-5b=3 can someone please help?