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?
Submitted by Nidhi, on August 20, 2020

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

Program:

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.






Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.





Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates


© https://www.includehelp.com some rights reserved.