#TC1017<\/a> #QUIZ09<\/a> <\/p>\n Here is how to do exponentiation asking the user for two numbers:<\/p>\n The program should ask the user for two numbers “a” and “b”, and then, raise “a” to the power of “b”. In order to do this, we will be using 4 variables:<\/p>\n We will be using a “do, while” loop, therefore, we need a variable to use as a counter and asign to it the value of 0. Lets remember the formula for exponentiation: photo by: http:\/ Our do while loop, will multiply “a”, “b” times, which means that the loop should multiply “a x a” as many times as the variable “b” states.<\/p>\n Here is how it should look:<\/p>\n do{<\/p>\n power=power*a;<\/p>\n counter=counter+1;<\/p>\n <\/p>\n }while(counter < b); <\/p>\n After that you can print out the new value of your variable “power” in order to show your result. <\/p>\n Here is a picture of the code and how it should run:<\/p>\n <\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":" #TC1017 #QUIZ09 Here is how to do exponentiation asking the user for two numbers:The program should ask the user for two numbers “a” and “b”, and then, raise “a” to the power of “b”. In order to do this, we will be using 4 variables:long … Continue reading \n
After asking the user for both numbers a and b, you will create a “do while” loop that works (while counter < b), because we will need the loop to work until we get to the value of b.<\/p>\n