Oleh: blogfirman | 27 Desember 2009

Program Looping Dengan Ekspresi while do

Berikut adalah beberapa contoh sederhana menggunakan ekspresi while do pada Pemrograman Pascal.

  • Contoh Program 1.
  1. program while_1;
  2. uses wincrt;
  3. var
  4. i:integer;
  5. begin
  6. i:=3;
  7. while(i>2) do
  8. begin
  9. writeln(‘ * ‘);
  10. end;
  11. end.
  • Contoh Program 2
  1. program while_2;
  2. uses wincrt;
  3. var
  4. i:integer;
  5. begin
  6. i:=3;
  7. while(i>2) do
  8. begin
  9. writeln(‘ * ‘);
  10. i:=i-1;
  11. end;
  12. end.
  • Contoh Program 3
  1. program while_3;
  2. uses wincrt;
  3. var
  4. i,n,jumlah:integer;
  5. begin
  6. jumlah:=0;
  7. writeln(‘masukkan i = ‘);readln(i);
  8. while(i>0) do
  9. begin
  10. writeln(i);
  11. jumlah:=jumlah+i;
  12. i:=i-1;
  13. end;
  14. writeln(‘jumlah’,jumlah);
  15. end.

Baca juga :

  • Contoh Program Case Of

https://blogfirman.wordpress.com/2009/12/27/case-of-dan-contoh-programnya-pada-pascal/

  • Contoh Program If..then..

https://blogfirman.wordpress.com/2009/12/27/program-menggunakan-case-of-dan-if-then/


Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

Kategori

%d blogger menyukai ini: