Q:

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

belongs to collection: C# Basic Programs | basics

0

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

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

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 BaseExplonent1Exponent2Division, and Result are initialized with 0. Then we took user input into BaseExponent1, 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.

 

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

C# Basic Programs | basics

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
C# program to demonstrate the example goto stateme... >>
<< C# program to demonstrate the example of the right...