Generate all combinations of 1, 2 and 3
C program to generate all combinations of 1, 2 and 3.
Program
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,k;
for(i=1;i<=3;i++)
{
for(j=1;j<=3;j++)
{
for(k=1;k<=3;k++)
{
printf("\n%d%d%d",i,j,k);
}
}
}
getch();
}
Output
111
112
113
121
122
123
131
132
133
211
212
213
221
222
223
231
232
233
311
312
313
321
322
323
331
332
333