Introduction
In this blog, we are going to see the calculation power of Exponent Method in C# programming language.
We're going to use that the same basic console programs.
What is the Exponent Method?
An exponent refers to the number of times a number is multiplied by itself.
For example, 2 to the 3rd means: 2 x 2 x 2 = 8. 2 to the power 3 is not the same as 2 x 3 = 6. Remember that a number raised to the power of 1 is itself.
Let's start!
Calculate Power Exponent value
  1. using System;
  2. class Expo {
  3. static void Main() {
  4. double m, n;
  5. Console.WriteLine("Enter the Number : ");
  6. m = double.Parse(Console.ReadLine());
  7. Console.WriteLine("Give the Exponent : ");
  8. n = double.Parse(Console.ReadLine());
  9. double value1 = Math.Pow(m, n);
  10. Console.WriteLine("Result : {0}", value1);
  11. Console.ReadLine();
  12. }
  13. }
Addition of Exponent of the same base
  1. using System;
  2. class ExpoAdd {
  3. static void Main() {
  4. Console.WriteLine("Enter the Base Value : ");
  5. double num = double.Parse(Console.ReadLine());
  6. Console.WriteLine("Give the First Exponent :");
  7. double exp1 = double.Parse(Console.ReadLine());
  8. Console.WriteLine("Give the Second Exponent :");
  9. double exp2 = double.Parse(Console.ReadLine());
  10. double add;
  11. add = exp1 + exp2;
  12. Console.WriteLine("Result is : {0}^{1} : {2}", num, add, Math.Pow(num, add));
  13. Console.ReadLine();
  14. }
  15. }
Subtraction of Exponent of the same base
  1. using System;
  2. class ExpoSub {
  3. static void Main() {
  4. Console.WriteLine("Enter the Base Value : ");
  5. double num = double.Parse(Console.ReadLine());
  6. Console.WriteLine("Give the First Exponent :");
  7. double exp1 = double.Parse(Console.ReadLine());
  8. Console.WriteLine("Give the Second Exponent :");
  9. double exp2 = double.Parse(Console.ReadLine());
  10. double sub;
  11. sub = exp1 - exp2;
  12. Console.WriteLine("Result is : {0}^{1} : {2}", num, sub, Math.Pow(num, sub));
  13. Console.ReadLine();
  14. }
  15. }
Multiplication of Exponent of the same base
  1. using System;
  2. class ExpoMulti {
  3. static void Main() {
  4. Console.WriteLine("Enter the Base Value : ");
  5. double num = double.Parse(Console.ReadLine());
  6. Console.WriteLine("Give the First Exponent :");
  7. double exp1 = double.Parse(Console.ReadLine());
  8. Console.WriteLine("Give the Second Exponent :");
  9. double exp2 = double.Parse(Console.ReadLine());
  10. double mul;
  11. mul = exp1 * exp2;
  12. Console.WriteLine("Result is : {0}^{1} : {2}", num, mul, Math.Pow(num, mul));
  13. Console.ReadLine();
  14. }
  15. }
Division of Exponent of the same base
  1. using System;
  2. class ExpoDivi {
  3. static void Main() {
  4. Console.WriteLine("Enter the Base Value : ");
  5. double num = double.Parse(Console.ReadLine());
  6. Console.WriteLine("Give the First Exponent :");
  7. double exp1 = double.Parse(Console.ReadLine());
  8. Console.WriteLine("Give the Second Exponent :");
  9. double exp2 = double.Parse(Console.ReadLine());
  10. double div;
  11. div = exp1 / exp2;
  12. Console.WriteLine("Result is : {0}^{1} : {2}", num, div, Math.Pow(num, div));
  13. Console.ReadLine();
  14. }
  15. }
Thanks for reading... Cheers!