0% found this document useful (0 votes)
34 views4 pages

Solutions I.: 1. X 2 4 6 8 10 I 5 2. I J 1 5 1 6 2 5 2 6 3 5 3 6 3

The document contains 10 programming problems in Pascal with solutions: 1. A program to count down the number of baby chickens that die each day. 2. A program that outputs alternating '*' and '#' characters based on whether the number is even or odd. 3. A program that outputs triangle patterns of increasing and decreasing '*' characters. 4. A program that calculates and prints triangle numbers up to 10. 5. A program that prints multiplication tables within a given range. 6. A program that checks a password in 3 attempts, and prints access messages. 7. A program that finds the maximum value from a set of input data.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views4 pages

Solutions I.: 1. X 2 4 6 8 10 I 5 2. I J 1 5 1 6 2 5 2 6 3 5 3 6 3

The document contains 10 programming problems in Pascal with solutions: 1. A program to count down the number of baby chickens that die each day. 2. A program that outputs alternating '*' and '#' characters based on whether the number is even or odd. 3. A program that outputs triangle patterns of increasing and decreasing '*' characters. 4. A program that calculates and prints triangle numbers up to 10. 5. A program that prints multiplication tables within a given range. 6. A program that checks a password in 3 attempts, and prints access messages. 7. A program that finds the maximum value from a set of input data.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

SOLUTIONS I.

1. X = 2 i=5 2. I 1 1 2 2 3 3 3. 4 j 5 6 5 6 5 6 6 8 10

4.
program a_ayam2; uses wincrt; var i,n:integer; begin write('jumlah anak ayam : ');readln(n); for i:= n downto 1 do begin if i<>1 then writeln('anak ayam turun ',i,', mati satu tinggal ',i-1) else writeln('anak ayam turun ',i,', mati satu tinggal induknya'); end; end.

5.

Kamus: i, x : integer Algoritma : Input (x) For i 1 to x do if (i mod 2 = 0) then output(*) else output(#) endif endfor

PASCAL
program tes; uses wincrt; var i, x : integer; begin write('jumlah baris : ');readln(x); For i := 1 to x do begin if (i mod 2 = 0) then writeln(i,'*':3) else writeln(i,'#':3); end; end.

6. program tes1;
uses wincrt; Var i,j : integer; begin For i:= 3 downto 1 do begin for j:= i downto 1 do write('*'); writeln; end; For i:= 1 to 3 do begin for j:= 1 to i do write('*'); writeln; end; End.

7.
program ex7; uses wincrt; var i, triangle_number : integer; begin triangle_number:= 0; writeln ('Triangle numbers: '); for i := 1 to 10 do begin triangle_number := triangle_number + i; writeln (triangle_number); end; readln; end. 8. program ex8; uses wincrt; var i, j,k, s, f: integer; begin write ('Enter starting point for multiplication tables : '); readln (s); write ('Enter finishing point for multiplication tables : '); readln (f); for i:= s to f do begin writeln('i = ', i); for j := 1 to 10 do write (j:3, ' x ', i, ' = ', j * i); writeln; end; end.

9. program ex9; uses wincrt; var pass,f: string; i: integer; begin write ('Isi Password : '); readln (pass); i:=1; clrscr;writeln(== LOGIN ==); while i <= 3 do begin writeln;writeln('loop ke-',i); write ('Your Password : '); readln (f); writeln; if pass=f then begin writeln ('Welcome ',f); i:=4; end else if i <> 3 then writeln('Invalid password, try again !') else Writeln(Sorry ,f,', Unauthorized user'); i:=i+1; end; end. 10. program ex10; uses wincrt; var n, data,i,maks: integer; begin write ('jumlah data : '); readln (n); i:=1; repeat begin write ('data ',i,' : '); readln (data); if data > maks then maks:=data; i:=i+1; end; until i>N; writeln('maximum = ',maks); end. writeln;

You might also like