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

Which amendment provides that the government cannot infringe on citizens' rights to bear arms?a. Firstb. Secondc. Fifthd. Sixthe. None
What is a fixed social class system?
Arrange these components of the mammalian immune system as it first responds to a pathogen in the correct sequence Pathogen is destroyed Lymphocytes secrete ant
A researcher finds that of 1000 people who said that they attend a religious service at least once a week, 31 stopped to help a person with car trouble. Of 1200
High-energy bonds between phosphate groups in nucleotide triphosphates (nucleotides in which three phosphate groups are attached to the 5′ carbon atom of the de
what are the roots of the quadratic equation x2 - 2x = 8x - 21
Under whos rule would athenian democracy begin to evolve into something that we would call and aristocracy
Algebra 1-Please help
24 increased by twice Gail's score
5. How did Progressives shape public policy?