program analisa numerik dengan metode tabulasi
Program metode_tabulasi;
uses wincrt;
label ulang;
var
x,x1,x2,xa,xb,xc,y,y1,y2,ya,yb:real;
I,j,k:integer;
ab:char;
begin
ulang: .
clrscr;
writeln('Tentukan akar penyelesaian dengan Metode Tabulasi dari f(x)=x^3-7x+1');
writeln;
write('masukkan nilai x1 ='); { * Nilai variable X pertama * }
readln(x1);
y1 := x1* x1* x1 - 7 * x1 + 1;
Writeln(' f(',x1:0:2,')=',y1:0:4);
repeat
begin
write('masukkan nilai x2 =');
readln(x2);
y2 := x2 * x2 * x2 - 7 * x2 + 1;
writeln(' f(',x2:0:2,')=',y2:0:4);
writeln;
writeln('Syarat (x1*x2)<0'); x2="',y1*y2:0:5);"> x2 then
begin
xa := x1;
xb := x2;
end
else
begin
xa := x2;
xb := x1;
end;
xc := (xa - xb) /10;
i:=0;
repeat
begin
i:=i+1;
x := xb + xc * I;
ya := x * x * x - 7 * x +1;
yb :=( x - xc) *(x - xc) *(x - xc) - 7 * (x - xc)+1;
end;
until (ya * yb) <0; x="',x);" error="',abs(y));" ab="'Y')" ab="'y')" style="font-weight: bold;">program input matrix
program input_matrix;
uses wincrt;
var
i,j,b,a:integer;
begin
a:=1;
writeln;
writeln;
write('masukan baris ');read(a);
write('masukan kolom ');read(b);
for i:= 1 to a do
begin
for j:= 1 to b do
begin
writeln(' (' ,i,' , ' ,j, ') ');
end;
end;
end.
program mencari faktorial
program faktorial;
uses wincrt;
var
i,j,n,a:integer;
begin
writeln('nama : Afit Miranto');
writeln('NPM : G1D009001');
writeln('PRODI : Teknik Elektro');
write('masukkan nilai n: ');
readln(n);
writeln('nilai faktorialnya adalah ');
for i:=1 to n do
begin
for j:=1 to i do
begin
a:=1;
for j:=1 to i do
a:=a*j;
end;
write(a, ' ');
end;
readln;
donewincrt
end.
program faktorial2
Program Faktorial_pascal;
uses wincrt;
function Faktorial(a:integer):longint;
begin
if (A=1)then
Faktorial:=1
else
Faktorial:=a*faktorial(a-1);
end;
var
x:integer;
begin
clrscr;
writeln('Faktorial Sequence');
writeln;
write('Berapa Faktorial : ');readln(x);
writeln(x,' faktorial ','= ',faktorial(x));
writeln;
write('Tekan Sembarang Tombol untuk keluar...');
readln;
donewincrt
end.
program data string
program data_string;
uses wincrt;
var
nama,npm,prodi,fakultas:string;
tahunlahir,umur:integer;
jeniskelamin:char;
begin
writeln(' welcome ');
writeln('-------------------------');
write('Nama : ');
readln(nama);
write('NPM : ');
readln(npm);
write('Prodi : ');
readln(prodi);
write('Fakultas : ');
readln(fakultas);
write('Tahun Lahir : ');
readln(tahunlahir);
write('jenis kelamin anda (L/P)? ');
readln(jeniskelamin);
umur:=2010-tahunlahir;
writeln('hello good morning ',nama, ' how are you today....????');
writeln('npm anda: ',npm);
writeln('dari prodi : ' ,prodi);
writeln('umur anda saat ini: ',umur,' tahun');
write('anda seorang ');
begin;
if (jeniskelamin='L') or (jeniskelamin='l') then write('laki-laki')
else write('perempuan');
end;
readln;
donewincrt;
end.
program luas keliling lingkaran
program luas_keliling_lungkaran;
uses wincrt;
label ulang;
var
r:integer;
l:real;
k:real;
ab:char;
const
phi=3.14;
begin
ulang:
clrscr;
writeln('PROGRAM MENCARI LUAS DAN KELILING LINGKARAN');
write('jari-jari= ');readln(r);
l:=phi*r*r;
k:=2*phi*r;
writeln('luas lingkaran= ',l:4:2);
write('keliling lingkaran= ',k:4:2);
writeln('Apakah anda ingin mengulanginya (y/t): ');
readln(ab);
if (ab='y') or (ab='Y') then
begin
goto ulang;
end
else
donewincrt;
readln
end.
program bahasa pascal bagian 3
Categories:
program bahasa pascal
0 comments:
Post a Comment