C# program to find the division of exponents of the same base

Here, we are going to learn how to find the division of exponents of the same base using C# program? By Nidhi Last updated : April 15, 2023

Finding Division of Exponents

Here we will create a C# program to find the division exponents of the same base in C#.

C# code to find the division of exponents of the same base

The source code to find the division of exponents of the same base in C# is given below. The given program is compiled and executed successfully on Microsoft Visual Studio.

//Program to find the division of 
//exponents of the same base in C#

using System;

class ExpDemo
{
    static void Main()
    {
        double Base         = 0.0;
        double Exponent1    = 0.0;
        double Exponent2    = 0.0;
        double Division     = 0.0;
        double Result       = 0.0;

        Console.Write("Enter the value of base : ");
        Base = double.Parse(Console.ReadLine());
        
        Console.Write("Enter the value of first exponent :");
        Exponent1 = double.Parse(Console.ReadLine());

        Console.Write("Enter the value of second exponent :");
        Exponent2 = double.Parse(Console.ReadLine());
        
        Division = Exponent1 - Exponent2;
        Result = Math.Pow(Base, Division);

        Console.WriteLine("Result is : {0}^{1} : {2}", Base, Division, Result);
    }
}

Output

Enter the value of base : 3
Enter the value of first exponent :5
Enter the value of second exponent :3
Result is : 3^2 : 9
Press any key to continue . . .

Explanation

In the above program, we created an ExpDemo class that contains the Main() method. Here we created 5 variables Base, Explonent1, Exponent2, Division, and Result are initialized with 0. Then we took user input into Base, Exponent1, and Exponent2.

Division = Exponent1 - Exponent2;
Result = Math.Pow(Base, Division);

In the above statements, we found Division and Result, and then print the result on the console screen.

C# Basic Programs »


Related Programs



Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.