0% found this document useful (0 votes)
245 views

Program Utk Latihan v2

The document contains 14 Pascal program code snippets that demonstrate various programming concepts like variables, conditionals, loops, functions, and complex number operations. The programs range from simple assignments and conditionals to more advanced concepts like binomial coefficients, complex number exponentiation, and nested conditionals.

Uploaded by

Rifqi Syams
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
245 views

Program Utk Latihan v2

The document contains 14 Pascal program code snippets that demonstrate various programming concepts like variables, conditionals, loops, functions, and complex number operations. The programs range from simple assignments and conditionals to more advanced concepts like binomial coefficients, complex number exponentiation, and nested conditionals.

Uploaded by

Rifqi Syams
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 4

TES1.PAS Program Coba; Var a , b : integer; Begin a := 5; {1} b := 10; {2} writeln(a); {3} end.

TES2C.PAS Program Coba; Var a , b : integer; Begin a := 5; {1} b := 8; if a > b then {2} a := 2 {3} else b := a; end. TES3.PAS Program Coba; var a : integer; begin a := 5; while a < 10 do begin a := a + 1; end; a := a + 10; writeln; end. TES5.PAS Program Coba; Var a : integer; Begin a := 5; repeat a := a + 1; until a > 10; a := a + 20; writeln; end. TES8.PAS Program Coba; var a : integer; begin a := 5; while a < 10 do begin if a > 5 then writeln(a); a := a + 1; end; a := a + 10; writeln(a); end.

TES2D.PAS Program Coba; Var a , b : integer; Begin A := 5; {1} If a > 3 then {2} a := 2; writeln(a); end.

TES4.PAS Program Coba; Var a : integer; Begin for a := 5 to 10 do begin writeln(a); end; writeln; end. TES7.PAS Program Coba; var a , b, c : integer; begin a := 5; b := 8; c := 4; if (a > b) or (a > c)then begin a := 2; end else begin if b = a then b := a else b := c; end; readln;; end. SOAL://Buat Flow Chart, Flow Graph, Independent Path, Cyclomatic Complexity, Matrix.

Uji Kualitas/ Bayu Hendradjaya/ 03/10/13

TES9.PAS Program Coba; var a, b : integer; begin readln (b); for a := 1 to 10 do begin if a > b then writeln(a) else writeln(b); end; writeln(a, b); end. TES11.PAS Program Coba; Var a, b : integer; Begin Readln (a, b); Case a of 1 : if a > b then writeln(a); 2 : if a < b then writeln(b); end; writeln(a, b); end.

TES10.PAS Program Coba; Var a, b : integer; Begin Readln (a); Repeat if a > 3 then writeln(a); a := a + 1; until a > 5; writeln(a); end.

TES12.PAS Program Coba; var a : integer; begin a := 5; if a > 4 then begin while a < 10 do begin if a > 5 then writeln(a); a := a + 1; end; end else a := a + 10; writeln; end. ALGO19.PAS Program BinomialCoefficients; Var i, a, b : integer; m, n : integer; begin readln( m, n ); a := 1; if 2 * m > n then b := n - m else b := m; i := 0; while i <= b do begin a := (n - i ) * a + (i +1); i := i + 1; end; writeln( a ); end.

TES27.PAS Program Coba; var a , b, c : integer; begin a := 5; b := 8; c := 4; if a > b then begin a := 2; end else begin case b of 1 : b := a; 2 : b := a + 1; else b := c; end; end; writeln(a,b); end.

Uji Kualitas/ Bayu Hendradjaya/ 03/10/13

ALGO106.PAS Program ComplexNumberToARealPower; Var x, y, w, A, B : real; theta, phi, r : real; begin readln( x, y, w, A, B ); if x > 0 then begin theta := 0.0; phi := arctan(y/x)+theta; r := sqrt( x*x+y*y ); r := exp( w * ln(r)); a := r * cos( w * phi); b := r * sin( w * phi); end; if (x < 0) and (y >= 0) then begin theta := 3.1; phi := arctan(y/x)+theta; r r a b := := := := sqrt( x*x+y*y ); exp( w * ln(r)); r * cos( w * phi); r * sin( w * phi);

end; if (x<0) and (y<0) then begin theta := 3.1; phi := arctan(y/x)+theta; r r a b := := := := sqrt( x*x+y*y ); exp( w * ln(r)); r * cos( w * phi); r * sin( w * phi);

end; if (x=0) and (y= 0) then begin a := 0.0; b := 0.0; end; if (x = 0) and (y < 0) then begin phi := 1.5; r := sqrt( x*x+y*y ); r := exp( w * ln(r)); a := r * cos( w * phi); b := r * sin( w * phi); end; if (x = 0) and (y > 0) then begin phi := -1.5707963; r := sqrt( x*x+y*y ); r := exp( w * ln(r)); a := r * cos( w * phi); b := r * sin( w * phi); end; writeln(a,b) end. Uji Kualitas/ Bayu Hendradjaya/ 03/10/13

Uji Kualitas/ Bayu Hendradjaya/ 03/10/13

You might also like