helinwasman2001
helinwasman2001 helinwasman2001
  • 20-12-2020
  • Computers and Technology
contestada

write an algorithm and draw a flowchart to calculate
2^4 using a loop approach?
​

Respuesta :

jacobEwing
jacobEwing jacobEwing
  • 20-12-2020

Answer:

I'm not about to write a flow chart for you, but here's a quick demo of how to do it:

doPower(2, 4);

function doPower(base, power){

   var result = 1, p;

   for(p = 0; p < power; p++){

       result *= base;

   }

   return result;

}

That function will only work for positive integer exponents of course.

Answer Link

Otras preguntas

what is a balanced equation of the neutralization of acetic acid (i.e.vinegar) and sodium
How did the cotton gin impact the backcountry in South Carolina?
Which equation could generate the curve in the graph below? y = 9x2 + 6x + 4 y = 6x2 – 12x – 6 y = 3x2 + 7x + 5 y = 2x2 + 8x + 8
External persuasive messages, with the exception of those that emphasize price, are generally based on A. strong logical appeals. B. the scarcity principle o
Expansionists were people who ______. A) believed the only way to ensure the country’s prosperity was to decrease the territory of the United States B) be
What is 25% of $1200? A) 900 B) 250 C) 600 D) 300
what is tge best way to revise the senctence so that the punctuation is correct? The phone call from the admissions office made me happy
Help please, thank you, I'm crying for help. :(
Determine whether each statement is a description of a physical property or a chemical property. Sodium metal reacts vigorously with water to produce hydrogen g
What are the causes of Antigens ? Please answer !!!