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

Rachel has 21 inche Beats she wants to use all of them to make a square picture frame what will be the length of each side ?
What was shown by both Redi’s and Pasteur’s experiments?
A ribbon is 12 3/8 feet long.Into how many 3/4-foot pieces can it be cut?
How many hours is it from New York to Colombia to Ecuador? By flying.
what is the most intense or exciting part of a story
Which of the following statements about territories is false? a. Territories are always self-governing. b. Territories are not sovereign. c. Territories ofte
what is -10 minus -6
Which equation represents a line that passes through (–9, –3) and has a slope of –6?
Aria drank 500 milliliters of water after her run.Her best friend Andrea drank 0.75 of liter of water.Who drank more?
The Emancipation Proclamation freed enslaved people living where?