Um. You need to think some more about this: your code doesn't do what you think it will.
for(i=1, j=1; i<=a,j<=b; i++,j++){
Inside this loop,
i
and
j
will always have the same value; they will both start at one, then they will both be two, and so on. I'm not sure when they will stop, because I've not seen a condition with a comma in it before and I doubt it will compile - I'm on a tablet and have no C compiler at the moment s I can't check, but I don't think it's valid C code.
Probably, you need a nested pair of loops, rather than a single loop...