Help writing code

I need a code that allows the user to specify the outer loop's ending value and increment value. the ending value determines ending number of asterisks and increment value determines number of asterisk to repeat.

thanks
can anyone help with this code please?
Show us what you have so far, and we can help you over the rough spots. But we do not do the work for you.
int main()
{
for (int outer = 2; outer < 11; outer += 2)
{
for (int nested = 1; nested <= outer; nested += 1)
cout << '*';
//end for
cout << endl;
}

system("pause");
return 0;
} //end of main function

that is what i started with and i have to modify it to what i said in my first post.
i can't figure out how to do it
I need a code that allows the user to specify the outer loop's ending value


Pretty straight forward.

1) get a value from the user (cin) - put it in a variable

2) use that variable in your loop condition.
i am still having trouble. i am new to programming so i don't know a lot about it.
i declared my variables but i do not know how to put them in the loop. i feel stupid.

my variables are endValue and increment
Do you know how for loops work?

1
2
3
4
for( initialize; loop_condition; increment )
{
  // ...
}


The "initialize" section is run once, when the loop starts.
The "loop_condition" section is checked every time the loop runs. If it is false, the loop exits.
The "increment" section is run every time the loop finishes one iteration.

So take a look at your outer loop:

 
for (int outer = 2; outer < 11; outer += 2)


Here, your "initialize" section is int outer = 2; This means you create a variable named outer, and it has a starting value of 2.

Your "loop_condition" is outer < 11. This means that the loop will continue to run as long as outer is less than 11. Once outer is greater than or equal to 11, the loop will exit.

Your "increment" section is outer += 2, which means that every time the loop completes one iteration, your outer variable is increased by 2.



So now if you have new variables for a new increment and endvalue, and you want to change this loop to use them -- it should be pretty straightforward where you need to put them.
Topic archived. No new replies allowed.