Prompt: Prompt the user for a number and an exponent. Computer the value of the
ID: 3584760 • Letter: P
Question
Prompt: Prompt the user for a number and an exponent. Computer the value of the given number (the base) raised to the power of the exponent. (For example, the number two raised to the fourth power is 16.) Their suggested correct answer: Get base Get exponent Set i to 1 Set answer to 1 While (i <= exponent) Set answer = answer x base Add 1 to i End loop Print answer Ok my problem... Set answer = answer x base if answer is 1 then we get base as answer every time in this loop for all values of i, as long as, i is equal to or smaller than 1. This does not express an exponential situation or value as asked for in the prompt. What am I not understanding or getting here?Explanation / Answer
go through the logic you've impemented for logical errors in program my be problem with assigning variables of different types!
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.