Answer to Question #298441 in C# for rexie

Question #298441

Write a function-oriented program that calculates the power value of the input base number and exponent number. Then display the power value. Sample input/output dialogue: Enter base number: 5 Input data Enter exponent number: 3 Second input data Power value: 125 Output (The computation is 53 = 5 * 5 * 5 = 125


1
Expert's answer
2022-02-16T10:21:21-0500
using System;
using System.Collections.Generic;
using System.Globalization;


namespace App
{
    class Program
    {
        static int power(int baseNumber, int exponentNumber)
        { 
            int result=1;
            for(int i=1;i<=exponentNumber){
                result*=baseNumber;
            }
            return result;
        }
        static void Main(string[] args){
            Console.Write("Enter base number: ");
            int baseNumber = int.Parse(Console.ReadLine());
            Console.Write("Enter exponent number: ");
            int exponentNumber = int.Parse(Console.ReadLine());
            int powerValue = power(baseNumber, exponentNumber);
            Console.Write("Power value: {0}", powerValue);


            Console.ReadLine();
        }
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS