I am trying to create a program in C to draw this pattern :
- 1 1 2 1 3 1
- 1 2 2 2 3 2
- 1 3 2 3 3 3
- 1 4 2 4 3 4
- 1 5 2 5 3 5
I checked the answer from solutions.
#include <stdio.h>
int main ()
{
int i;
int j;
for (i = 1 ; i <= 5 ; i++)
{
for (j = 1 ; j <= 3 ; j++)
{
printf("%i*%i",j,i);
}
printf("n");
}
return 0;
but I can’t understand why this code (Above) gives the previous result instead of this result :
- 1 2 3 1
- 1 2 3 2
- 1 2 3 3
- 1 2 3 4
- 1 2 3 5
Thanks in advance.