Off[General::spell1];
Clear[TriDiagonal,a0,d0,c0,b0];
TriDiagonal[a0_,d0_,c0_,b0_] :=
Module[{i,xmult},
  a = a0; d=d0; c=c0; b=b0;
  n = Length[b];
  x=Table[0,{i,n}];
  For[i=2,i<=n,i++,
    xmult = a[[i-1]]/d[[i-1]];
    d[[i]] = d[[i]]-xmult*c[[i-1]];
    b[[i]] = b[[i]]-xmult*b[[i-1]];];
  x[[n]] = N[b[[n]]/d[[n]],digit];
  For[i=n-1,1<=i,i--,
    x[[i]] = N[(b[[i]] - c[[i]]*
       x[[i+1]])/d[[i]],digit];];
 Return[x]; ]; 
 On[General::spell1];

Clear[digit];
digit = 7;

Clear[a,d,c,b, A]; 
a = {4,-4,0}; d={1,5,-5,-3};
c={2,3,1}; b={1,4,-2,2} ;
A= Table[Switch[i-j,-1,c[[i]],0,
d[[i]],1,a[[i-1]],_,0], {i,4},{j,4}];
MatrixForm[A]

TriDiagonal[a ,d ,c ,b ]

Clear[a,d,c,b, A]; 
a = {-1,-1,-1,-1,-1}; d={4,4,4,4,4,4};
c={-1,-1,-1,-1,-1}; b={1,2,3,4,5,6} ;
A= Table[Switch[i-j,-1,c[[i]],0,
d[[i]],1,a[[i-1]],_,0], {i,6},{j,6}];
MatrixForm[A]

TriDiagonal[a ,d ,c ,b ]