Compute Exponential Number using C#
Submitted by donbermoy on Wednesday, July 23, 2014 - 01:33.
In this article, i will introduce again some function in C# regarding the Math Functions, this is Math.Pow(). Math.Pow() Function in C# computes a number that has an exponent.It returns a specified number raised to the specified power.
So, now let's start this tutorial!
1. Let's start with creating a Windows Form Application for this tutorial by following the following steps in Microsoft Visual Studio 2010: Go to File, click New Project, and choose Windows Application.
2. Next, add two TextBoxes named TextBox1 and TextBox2 then leave it as blank. TextBox1 will be used as an input for a number and TextBox2 will be used as an input for the exponent. Now, add a Button named Button1 to compute the exponential number. You must design your interface like this:
3. Now, put this code in Button1_Click. This will compute your exponential number.
num1 holds the value of TextBox1 as we input it our main number, expo holds the value of TextBox2 as we declare it as our exponent, and the result variable holds the answer to the exponential number. We used the formula Math.Pow(num1, expo) to have the result pass through the variable result. Then it will get the answer in num1 and the expo as our exponent. Then it will display num1.ToString() + " to the power of " + expo.ToString() + " is" + " " + result.ToString().
Output:
For more inquiries and need programmer for your thesis systems in any kind of programming languages, just contact my number below.
Best Regards,
Engr. Lyndon Bermoy
IT Instructor/System Developer/Android Developer/Freelance Programmer
If you have some queries, feel free to contact the number or e-mail below.
Mobile: 09488225971
Landline: 826-9296
E-mail:[email protected]
Add and Follow me on Facebook: https://www.facebook.com/donzzsky
Visit and like my page on Facebook at: https://www.facebook.com/BermzISware

- private void button1_Click(object sender, EventArgs e)
- {
- int num1;
- int expo;
- int result;
- num1 = System.Convert.ToInt32((textBox1.Text));
- expo = System.Convert.ToInt32((textBox2.Text));
- result = System.Convert.ToInt32(Math.Pow(num1, expo));
- MessageBox.Show(num1.ToString() + " to the power of " + expo.ToString() + " is" + " " + result.ToString());
- }

Add new comment
- 302 views