You are on page 1of 1

Program Interpolasi_Langrange; Uses Wincrt; Var n,i,j:integer; xp,yp,hasil,L:real; x : array [0..10] of real; y : array [0..

10] of real; Begin Writeln ('polinom berderajat n='); Readln (n); For i:=0 to n do Begin Writeln ('x',i,'='); readln (x[i]); Writeln ('y',i,'='); readln (y[i]); End; Write ('xp='); Readln (xp); {Proses} Hasil:=0; For i:=0 to n do Begin L:=1; For j:=0 to n do If j<>i then Begin L:=L*((xp-x[j])/(x[i]-x[j])); End; Hasil:= Hasil + L*y[i]; End; {Hasil} Begin Writeln ('yp=',hasil :2:3); End; End.

You might also like