Algorithm 8: Computing the power of a number Input:r, is a real number a E R, n is an integer number, n e Z Output: a" 1: р+1 2: for i +1 ton do 3: p px x 4: end for 5. return n

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter2: Problem Solving Using C++using
Section2.4: Arithmetic Operations
Problem 6E
icon
Related questions
Question

Calculate the total number of primitive operations executed for the following algorithm?

 

Algorithm 8: Computing the power of a number
Input:x, is a real number r E R, n is an integer number, n e Z
Output: a"
1: р+-1
2: for i +1 to n do
p px x
4: end for
3:
5: return p
Transcribed Image Text:Algorithm 8: Computing the power of a number Input:x, is a real number r E R, n is an integer number, n e Z Output: a" 1: р+-1 2: for i +1 to n do p px x 4: end for 3: 5: return p
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT