/
int Num = 18;
cout << " Multiples of 9 from 27 to 81:\n";
while ( num <= 81 )
{
Num = Num + 9;
cout << Num << " ";
num++;
}
int n = 1;
int NUM = 0;
cout << " 3 raised to the power of n + 1 where n is 1 to 10\n";
while ( n <= 10)
{
3 * pow(n) + 1 = NUM;
cout << NUM << " ";
NUM++;
}
return 0;
}
my program should produce the output
Multiples of 9 from 27 to 81:27 36 45 54 63 72 81
3 raised to the power of n + 1 where n is 1 to 10: 4 10 28 82 244 730 2188 6562 19684 59050
I assume the pow you are using is the one included in cmath, it takes 2 arguments, in this case 3.0 and n+1.
You're also mixing up math with c++, NUM should be assigned the equation: NUM = pow(3.0, n+1);
Finally you're incrementing NUM in the while loop, this also means that n is never changed and you'll have an infinite loop, so change that to n++ instead.
int n = 1;
int sum = 0;
cout << " 3n=1 where n is 1 to 10\n";
while ( n <= 10)
{
sum += pow(3.0, n+1); //note +
cout << sum << " "; // maybe endl would make it look better?
n++;
}