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 good sentence for nomad
what did a lord, knight, and serf do for each other?
the strength of the force of gravity between two objects depend on?
I really need help with this!!!!!!!!!!!!!!!!! Someone plz help me
What does this example of personification mean?"The funeral raced by me in a blur."
Describe something that you think is a public good. Explain how it is non-excludable and non-rival. State whether you think the good should be provided by the g
How do I write a word problem for 1.75 ÷ .5
to the nearest tenth of a percent, what is 8/13 written as a percent? Answers: A. 0.6%
What causes sediment to change into hard rock
Find the x intercepts of y=2x^2+x-21