0

I want to calculate remainder of all the values inside nested loop with all the numbers inside the loop. for example

when

```
a=1 , b=1, c=remainder
a=2, b=1, c=remainder
a=3, b=1, c=remainder
a=1, b=2, c=remainder
a=2, b=2, c=remainder
a=3, b=2, c=remainder
a=1, b=3, c=remainder
a=2, b=3, c=remainder
a=3, b=3, c=remainder
```

and here is what i've coded.

```
int main(void)
{
int a,b,c,d;
for (a=1;a<4;a++)
{
for (b=1;b<4;b++)
c=a%b;
printf ("a=%d,b=%d,c=%d\n",a,b,c);
}
getche ();
}
```

When i'm writing `c=a%b`

over `for (b=1;b<4;b++)`

nothing is happening and program is not running and when i am writing `c=a%b`

under `printf ("a=%d,b=%d,c=%d\n",a,b,c);`

the Output is

```
a=1, b=1, c=-28692
a=1, b=2, c=-28692
a=1, b=3, c=-28692
a=2, b=1, c=1
a=2, b=2, c=1
a=2, b=3, c=1
a=3, b=1, c=2
a=3, b=2, c=2
a=3, b=3, c=2
```

why it is showing the incorrect remainder

*Edited 6 Years Ago by Xufyan*: n/a