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

Someone please help me on this question!!!!!
You want to order carpet for an area in your house. The room measures 12 feet by 10 feet. Remember, Area = Length × Width. If each square yard of carpet cost
solve for x: 1/2x + 6 =11
Who developed the early box camera known as Kodak? A. Ernst Leitz B. Franke and Heidecke C. Polaroid D. George Eastman
help please whats the answer
During a recent shopping trip,Erik bought 5 shirt that cost 18.95 each.How much change did erik receive if he paid with a 100 bill?
What is the center of an atom called
After you select a cell with an error indicator, you can click the error checking _______ to display additional information about the possible error and determi
Number 18. What is the value of f(3) if ? f(x)= -5/2x + 4 A. 0.4 B. –3.5 C. 11.5 D. –11.5 E. 3.5
Read this excerpt from a Raisin in the Sun: BENEATHA Mama, Asagai asked me to marry him today and go to Africa- What two concepts are most represented in this e