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

which of the followiing is not a function
which cooks food faster, an aluminium pot or a copper one?​
In the year 2000, a house was valued at $60 000. In 2010, the same house was valued at $80 000. Work out the value of the house in 2010 as a percentage of it
What is the equation of the line that has a slope of -4 and passes through the point (2, 3)?
What does it mean that the US Constitution is the "supreme law of the land"? O It is the world's first constitution. O It is above all state constitutions. OIt
4 12 + 17 < -18 * True False
Elizabeth Cady Stanton's Early Influences Which question would best help the reader understand Stanton’s viewpoint in the excerpt
C Why do governments often regulate business in a capitalist society? Oto prevent the overproduction of products Oto guarantee the development of big business O
Find the length of the side TS
The molecular bonds between atoms are considered to be _____ in a food item, before you eat it. Group of answer choices chemical energy kinetic energy an exampl