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

name two methods that can be used to break down compounds into simpler substance
The type of protozoan that uses psuedopods (false feet) to move is a. a ciliate protozoan. b. an amoeboid protozoan. c. a sporozoan. d. an algae
How have the systems of law dating from Ancient Rome influenced the U.S. legal system
What role does DNA play in the expression of traits
How do I find the formula for the sequence: 3, 6, 18, 72, 360, ...
how might a suit of armor be a good analogy for function  of the skeletal system
What disadvantage did the patriots face in fighting the British ??????
You decide to add up all the work you did yesterday. If you accomplished 10,000 newton·meters of work yesterday, how much work did you do in units of joules?
A broken clock is set correctly at 12:00 noon. However, it registers only 20 minutes for each hour. In how many hours will it again register the correct time?
What is one third plus one fourth and what is 1/3 + 1/2