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

Probability maths question . need help asap
quadrilateral a’b’c’d’ is a result of reflecting quadrilateral ABCD across the line L Select all correct statements about the unchanged properties of quadrillio
Please help. This pertains to radical exponents (Algebra 2) What is the simplest form of: [tex](9x\sqrt[4]{y})^{3/2}[/tex] I cannot seem to find the answer. T
Please help me #1-10 please
Why didn’t the loyalists join the american revolution?
A nudibranch is a jelly-bodied animal that lives in shallow ocean waters. They range in size from less than an inch to 12 inches, and they have a life cycle of
(2a+3b)^2 =20 a.b=1 4a^2+9b2=
Explain how mass and energy is conserved within a cell.​
Everyone will experience most emotions at some point in their life. Please select the best answer from the choices provided. T F
What is a trade union?