1
Answer

Coding a (for loop) for raising a power

Luis  Carmona

Luis Carmona

12y
2.2k
1
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)