I am tring to write a loop that will do exponents without using the cmath class.
this is what I have so far but im getting a infinite loop, i think im over thinking this can anyone help?
Code:
// Output: 1 2 4 ... 2^(num - 1)
// First num powers of 2, ^ denotes exponentiation/power
// There is no operator to do exponentiation in C++.
cout << "\n 6. ";
int a = 1;
cout << a;
for (int i = 0; i <= num; i++)
{
int b = 2;
int c = 0;
int d = 1;
while (d < num)
{
c *=b;
}
cout << c;
}
Comment