Luis  Carmona

Luis Carmona

  • NA
  • 1
  • 2.5k

Coding a (for loop) for raising a power

Nov 27 2011 10:48 PM
I could use some help on this code that I am writing. I am trying to code a for loop to raise a power of a number here is what I have so far any sugg.

     long lngBase = 0;    
     long lngRaise = 0;
     long lngResult = 1;

     lngBase = Convert.ToInt64(txtBase.Text);
     lngRaise = Convert.ToInt64(txtExponent.Text);

  for (lngBase = 1; lngBase <= lngRaise; lngBase++)
  {
     lngResult = lngBase * lngRaise;
  }

     txtResult.Text = lngResult.ToString("n0");

Answers (1)