Warshall's algorithm for transitive closure
Arrays are 0-indexed

In C, arrays are 0-indexed. Not 1-indexed. So you're skipping the first element and running off the back in these loops. You want:

for(i=0;i&lt;n;i++)
  for(j=0;j&lt;n;j++)
    for(k=0;k&lt;n;k++)


Use braces

Nested logic is crying for braces to make it easer to read:

for(i=0;i&lt;n;i++) {
  for(j=0;j&lt;n;j++) {
    for(k=0;k&lt;n;k++) {
    }
  }
}


That'll also future proof anything else you add into these loops. What if you added logging? You'd have to go back and add braces then anyway. It's a good habit to get into. Always braces.

maximum()

There's actually no reason for this function. The logic you want is:

R(k)[i, j] = R(k-1)[i, j] or (R(k-1)[i,k] and R(k-1)[k,j])


We can just do that directly using bitwise math:

for(i=0;i&lt;n;i++) {
  for(j=0;j&lt;n;j++) {
    for(k=0;k&lt;n;k++) {
      p[i][j] = p[i][j] | (p[i][k] &amp; p[k][j]);
    }
  }
}