# Help with exponents loop, not allowed to use pow() library



## zalery (Oct 21, 2007)

so i'm trying to set up this exponents loop, keep in mind this is my first year in computer science so my knowledge of script is somewhat minimal. basically this assignment (or at least part of it) tells us to have the user enter 2 numbers, (left and right) and to output the correct answer using a loop to calculate. my idea was to use to write a script so the number the user inputs for the right side will determine the number of times the loop runs. this is what i have so far but it's not working. can anyone help please?

#include <iostream>

using namespace std;

int main()
{
int left, right;

cout << "Enter left and right side: ";
cin >> left >> right;



for (right;

left *= right;






system("pause");
return 0;
}


----------



## hcm1 (Nov 5, 2007)

is your for loop correct?
http://www.hcmediation.com


----------



## Bookworm99 (Jun 5, 2007)

hcm1, I don't think that posting links which have nothing to do with the topic is allowed here. 

zalery, what is the calculation you're supposed to be preforming? What outcome do you want?


----------



## MattBro (Nov 11, 2006)

Hi Zalery,

here:


```
#include <iostream>
using namespace std;


void main()
{
     int left;   // base
     int right; // exponent

     cout << "Enter the base: ";
     cin >> left;
     cout << "\nEnter the exponent: ";
     cin >> right;

     // calculate
     int iResult = left;

     for(int i = 0; i < right; i++)
     {
           iResult *= left;
     }

     cout << "\n\n" << left << " raised to " << right << " is: " << iResult;
}
```


----------



## babywildcat (Mar 1, 2009)

that's right, except that:
for ( int i = 0, i < right - 1, i++ )
blah blah blah
:wink:


----------

