A preserved archive of the Logical Gamers community forums, 2009-2025. The original threads and posts, served read-only. Registration, posting and private messages are gone for good.

Need Help With C++ For Loops

810 views · started by ksrocks333 ·
#1
Need Help With C++ For Loops
Ok, I'm just starting C++ in my school, doing pretty good. But I need help with this one activity.

We have to ask the user to input a number and then output the multiples, AND the powers using FOR LOOPS.
I can do the multiples fine, but I'm having trouble getting the powers to work.

Can someone help me with the code?
#2
What do you mean "the powers"? The number to the power of 1 through X, or integer roots of the number?

What do you have so far?
#3
GAMEchief wrote:
What do you mean "the powers"? The number to the power of 1 through X, or integer roots of the number?

What do you have so far?


I mean the first 5 powers of the number the user inputs. So let's say the user input the number 2

It would show
2
4
8
16
32


I don't remember the code I have exactly, but I know the multiples of the number worked. I just need help with the powers.

I know I have to declare a new variable and then make it the number that the user inputs but then I don't get how to output it five times while increasing it by the power of the numbers...

Code is something like:
int (main
{
int num, x, y;

cout<< "enter a number";
cin>>num;
cout<<endl;

for(x=0; x<=5; x++)
{
cout<<x<<endl;
}
(deffinitely missing something there, but that's for powers, but it's working fine, i'm just forgetting to type something here)

and then I need a for loop for multiples of the number so

for(y=.......HELP)