Q1.Write an algorithm to find the exponent of a given number .Ans: Planning the Solution:Input: A number and its exponent.Required Output: Exponent of given number.Processing: Multiply the number as many times as its exponent.Algorithm:Step 1: StartLet the numbers, N be 8 and its exponent,E be 5.Step 2: Initialize product(P) and K to 1.P=1, K=1Step 3: Find the Product(P)P=P*NStep 4: Increment K by 1.K=K+1Step 5: Check if the value of K is less than or equal to EIf K ≤ E then goto step 3 otherwise goto step 6.Step 6: Output PStep 7: Stop
Comments
Post a Comment