Simple Loop source code

Hello everyone. Can anyone help me with this problem using while or for or do loop?
The desired output should be like this:
_____________________________________
Enter a number : 5 //for example
1, 2, 3, 4, 5

Try again? Y/N
_____________________________________

I've tried various code loop code but I can't really make it. Thanks for any help.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <iostream>

int main(void) {
	int amount;
	char cont = 'y';
	while(cont == 'y') {
		std::cout << "Enter a number: ";
		std::cin >> amount;
		for(int i = 1; i <= amount; ++i)
			std::cout << i << ' ';
		std::cout << "\nContinue? <y/n>: ";
		std::cin >> cont;
	}
	return 0;
}

Is this what you are looking for?
Last edited on
Thank you. I'll try it then I'll say if it is. Thank you again.
Oh, I have another problem, since I not yet familiar with loop codes, would you be so kind so make a simple flow chart of this. Thank you.
What exactly would you want it to look like? Just write up a quick example while I go take a shower.
Topic archived. No new replies allowed.