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 trk.
Can someone help me with the code?
Results 1 to 3 of 3
Thread: Need Help With C++ For Loops
- 07 Mar. 2010 06:03pm #1
Need Help With C++ For Loops
LG's Dyke. Enough. Said.
- 07 Mar. 2010 06:21pm #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?
- 07 Mar. 2010 06:32pm #3
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)LG's Dyke. Enough. Said.