I am working on printing a loop statement.

I worked on this to try the concept:

#include "stdafx.h"
#include "stdio.h"

int main()
{
	int times,num;
	for (times=1; times<3; times++)
	{
		for (num=1; num<5; num++)
		{ printf("%d",num); }
		printf("\n");
	}
	return 0;
}

What I need is to print out
012
0123
012
01
01
01
01

but cannot get it to work so that is why I worked on the example above.

Thanks for your help!

try this: printf("%03d", num); In "%03d", the 3 means minimum of 3 digits, 0 means print 0's if num is less than 3 digits. So num = 1, that will print 001

what about printing in columns and rows
012
0123
012
01
01
01

what about printing in columns and rows
012
0123
012
01
01
01

you mean like this?

0    1    2
0    1    2    3
0    1    2
0    1
0    1

Yes

you mean like this?

0    1    2
0    1    2    3
0    1    2
0    1
0    1

If you want to put 5 spaces between columns, and the digits left-justified in the field, then use the - (minus) to left-justify printf("%-5d%-5d%-5d", 0, 1, 2);