I am making a simple calculator in visual studio where I have put different buttons including a square button, square root button, cube button and cube root button in my winform calculator. All other button work fine in the calculator but I don't know the code behind the square, sqrt, cube and cube root button so can you suggest me some code that will help me solve the problem in my calculator?
Loading
Khargesh RajputPosted Apr 11, 2015, 12:00 AM
Sam JonesPosted Apr 12, 2015, 5:12 PM
Sam JonesPosted Apr 12, 2015, 5:11 PM
Nitin GaurPosted Apr 11, 2015, 12:38 AM
u can try my simple code to run that funtionality..
code for SQR : textBox2.Text = (Convert.ToInt32(textBox1.Text) * Convert.ToInt32(textBox1.Text)).ToString();
code for SQRT : textBox2.Text = Math.Sqrt( Convert.ToDouble( textBox1.Text)).ToString();
code for CUBE : textBox2.Text = (Convert.ToInt32(textBox1.Text) * Convert.ToInt32(textBox1.Text) * Convert.ToInt32(textBox1.Text)).ToString();
code for CUBEROOT: textBox2.Text = Math.Pow(Convert.ToDouble(textBox1.Text), 0.3333333333333333).ToString();
hope this will help you !!