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

When a number gets assigned to a variable that already has a value __________?
A(n) _________ allows users to communicate and share information between computers
"although gdp is likely the best measure of economic activity in the economy, one reason why gdp is considered to be an imperfect measure is because:"
How did hitler turn Germany into a dictatorship using the enabling act ?
Defining hysteria and examining how it relates to the crucible example
Find k such that the equation kx^2+x+25k=0 has a repeated solution.
The four main systems of the earth are
You order two drinks for 2.49 each and an entree for 12.95. if sales tax is 5% what is your total bill
what are rational numbers
What does liberty in the Preamble mean? A. To insure domestic tranquility B. All for one and one for all C. The citizens of each state must share in the benefit