C# Program to Find the Division of Exponents of Same Base
Posted by Superadmin on August 10 2022 14:43:21

C# Program to Find the Division of Exponents of Same Base

 

 

This is a C# Program to perform division of exponents of same base.

Problem Description

This C# Program Performs Division of Exponents of Same Base.

Problem Solution

Here the power value for all same base is found.

Program/Source Code

Here is source code of the C# Program to Perform Multiplication of Exponents of Same Base. The C# program is successfully compiled and executed with Microsoft Visual Studio. The program output is also shown below.

/*
 *  C# Program to Perform Division of Exponents of Same Base
 */
using System;
class Program
{
    static void Main()
    {
        Console.WriteLine("Enter the Base : ");
        double num = double.Parse(Console.ReadLine());
        Console.WriteLine("Enter the First Exponent :");
        double exp1 = double.Parse(Console.ReadLine());
        Console.WriteLine("Enter the Second Exponent :");
        double exp2 = double.Parse(Console.ReadLine());
        double div;
        div = exp1 - exp2;
        Console.WriteLine("Result is : {0}^{1} : {2}", num, div, Math.Pow(num, div));
        Console.ReadLine();
    }
}
Program Explanation

In this C# program, we are reading the base, the first and second exponent value using the variables ‘num’, ‘exp1’ and ‘exp2’ respectively. The ‘div’ variable is used to compute the difference between the first and second exponent values and the power value for all same bases is found. Print the division of exponents of same base.

 
Runtime Test Cases
 
Enter the Base :
2
Enter the First Exponent :
4
Enter the Second Exponent :
3
Result is : 2^1 : 2