Nested Loops

Print to the screen the following sequence, namely 1, 2, 3, 4, 5, 1, 2, 3, 4, 1, 2, 3, 1, 2, 1.

I know I need to use a nested loop, can someone give me a hand with that?
Last edited on
Nothing? Anyone?
Start with a single loop that produces: 5,4,3,2,1.
5,4,3,2,1 or 1,2,3,4,5?
Last edited on
Am I getting warmer? lol, I'm so lost.

1
2
3
4
5
6
7
8
9
10
11

for (i=1; i<=5; i++)
{
   for (i=1; i<=4; i++)
   {
      for (i=1; i<=3; i++)
      {
         for (i=1; i<=2; i++)
         {
            for (i=1; i<=1; i++)
Last edited on
I don't think so.

1
2
3
4
5
6
void f(int n)
{
	for (int i=n;i>=1;i--)
		for (int j=1;j<=i;j++)
			printf ("%d, ", j);
}


f(5) will give the result.
Topic archived. No new replies allowed.