Makalah.docx

  • Uploaded by: Sulton Ibrahim
  • 0
  • 0
  • April 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Makalah.docx as PDF for free.

More details

  • Words: 5,585
  • Pages: 101
MAKALAH Tugas Program Bahasa C

Dosen Pengampu: Dr.Ir.Dra. Erdawaty Kamaruddin, M.Pd.

Disusun Oleh: Sulton Ibrahim (1512618078)

Pendidikan Teknik Informatika Fakultas Teknik Universitas Negeri Jakarta 2019

KATA PENGANTAR Segala puji dan syukur ke hadirat Tuhan yang Maha Esa atas kesehatan, kesejahteraan, serta karunia-Nya sehingga penulis dapat membuat dan menyusun makalah ini tepat waktu. Makalah ini berisi tentang materi konsep pemrograman tentang Bahasa C yang berisi 35 program dibuat untuk menyelesaikan tugas akhir semester satu mata kuliah konsep pemrograman Terima kasih kepada semua pihak atas bantuan dan saran-saran yang diberikan dalam membuat makalah ini. Makalah ini masih terdapat banyak kekurangan,baik dalam kalimat,kata, maupun tanda baca. Maka dari itu, penulis mohon kritik dan masukannya agar makalah ini sempurna

Jakarta,26 Januari 2019

Sulton Ibrahim

Daftar Isi BAB 1 .......................................................................................................................................................... 0 A. Program Deret ................................................................................................................................... 0 1.

Program Ascending Pertambahan 1 ................................................................................................. 0

2.

Program Descending Pengurangan 1 ............................................................................................... 2

3.

Program Deret Ganjil Ascending ..................................................................................................... 4

4.

Program Deret Genap Ascending .................................................................................................... 6

5.

Program Deret Ganjil Pangkat Dua ................................................................................................. 8

6.

Program Deret Descending Pangkat Dua ....................................................................................... 10

7.

Program Deret Ascending Pangkat Tiga ........................................................................................ 12

8.

Program Deret Descending Pangkat Tiga ...................................................................................... 14

9.

Program Deret Pangkat 3 Berlanjut ............................................................................................... 16

10.

Program Deret Ascending Pertambahan 5 ................................................................................. 18

11.

Program Deret Bilangan Segitiga .............................................................................................. 20

12.

Program Deret Bilangan Dikalikan 3 ......................................................................................... 22

13.

Program Deret Bilangan Pertambahan 6 .................................................................................... 24

14.

Program Deret Bergoyang 2 (Bilangan Ganjil Pangkat Tiga & Bilangan Genap) .................... 26

15. Program Deret Bergoyang 2 (Bilangan Descending Pengurangan 5 & Bilangan Ascending Pertambahan 6) ...................................................................................................................................... 28 16.

Program Deret Fibonanci ........................................................................................................... 30

17.

Program Deret Bergoyang 2 (Bilangan Pertambahan 1 & Bilangan Persegi) ........................... 32

18.

Program Deret Fibonacci ........................................................................................................... 34

19.

Program Deret Bergoyang 2 (Bilangan Pangkat 2 & Bilangan Pertambahan 2) ....................... 36

20.

Program Deret Bergoyang 2 (Bilangan Ascending & Descending Pangkat 3) .......................... 39

21.

Program Deret Bergoyang 2 (Dua Bilangan Pertambahan 3) .................................................... 42

22.

Program Deret Bergoyang 2 (Bilangan Pangkat 3 & Bilangan Pertambahan 7) ....................... 45

23.

Program Deret Bergoyang 2 (Bilangan Pertambahan 10 & Bilangan Pertambahan 5) ............. 48

24.

Program Deret Bergoyang 2 (Bilangan Pengurangan 3 & Bilangan Pengurangan 2) ............... 51

25.

Program Deret Bergoyang 2 (Bilangan Pertambahan 2 & Bilangan Pengurangan 2) ............... 54

26.

Program Deret Bergoyang 2 (Bilangan Pertambahan Kelipatan 2) ........................................... 57

27.

Program Deret Bergoyang 2 (Bilangan Pertambahan Kelipatan 2) ........................................... 59

28.

Program Deret Bergoyang 3 (Bilangan Pertambahan 5) ............................................................ 62

29.

Program Deret Bergoyang 2 (Bilangan Pertambahan Kelipatan 2) ........................................... 65

30.

Program Deret Bergoyang 3 (Bilangan Pertambahan 5) ............................................................ 68

B. Program Kreasi ............................................................................................................................... 71 1.

Program Pengecekan Kenormalan Denyut Nadi............................................................................ 71

2.

Program Hompimpa ....................................................................................................................... 72

3.

Program Aplikasi Pengisian Pulsa ................................................................................................. 79

4. Program Puzzle .................................................................................................................................. 83 5. Program Wartel .................................................................................................................................. 91

BAB 1 A. Program Deret 1. Program Ascending Pertambahan 1

Source code : #include <stdio.h> #include #include <windows.h> #include <stdlib.h> #include main ()

{ int s,t,u,v; s=1; u=v=0; system ("color 0A"); printf("Bilangan Bulat:1,2,3,4,5,6,7.....\n\n"); printf("Masukan jumlah suku yang akan dicetak : "); scanf("%i",&v); printf("\n"); printf("________________________________________________________ ________________________________________________________________\n\n" ); for (t=1;t<=v;t++) { printf ("%i\t",s); u=u+s; s=s+1; } printf("\n"); printf("________________________________________________________ ________________________________________________________________\n\n" ); printf("\nJumlah Deret = %i\n\n\n",u); getch(); system ("cls"); printf("\n\n\n\t\t\t\t\t\Terimakasih telah menggunakan program ini :D \n\n"); printf("\t\t\t\t\t\tCreated By Sulton Ibrahim\n\n"); printf("\t\t\t\t\t\t\ NIM 1512618078\n"); }

1

2. Program Descending Pengurangan 1

Source code: #include <stdio.h> #include #include <windows.h> #include <stdlib.h> #include main () { int w,x,y,z; w=100; y=z=0; system ("color 0A"); printf("Bilangan Bulat:100,99,98,97,96,95.....\n\n"); printf("Masukan jumlah suku yang akan dicetak : "); 2

scanf("%i",&z); printf("\n"); printf("________________________________________________________ ________________________________________________________________\n\n" ); for (x=1;x<=z;x++) { printf ("%i\t",w); y=y+w; w=w-1; } printf("\n"); printf("________________________________________________________ ________________________________________________________________\n\n" ); printf("\nJumlah Deret = %i\n\n\n",y); getch(); system ("cls"); printf("\n\n\n\t\t\t\t\t\Terimakasih telah menggunakan program ini :D \n\n"); printf("\t\t\t\t\t\tCreated By Sulton Ibrahim\n\n"); printf("\t\t\t\t\t\t\ NIM 1512618078\n"); sleep(3); }

3

3. Program Deret Ganjil Ascending

Source code : #include <stdio.h> #include #include <windows.h> #include <stdlib.h> #include main () { int a,b,c,d; a=1; c=d=0; system ("color 0A"); printf("Bilangan Bulat Ganjil:1,3,5,7,9,11.....\n\n");

4

printf("Masukan jumlah suku yang akan dicetak : "); scanf("%i",&d); printf("\n"); printf("________________________________________________________ ________________________________________________________________\n\n" ); for (b=1;b<=d;b++) { printf ("%i\t",a); c=c+a; a=a+2; } printf("\n"); printf("________________________________________________________ ________________________________________________________________\n\n" ); printf("\nJumlah Deret = %i\n\n\n",c); getch(); system ("cls"); printf("\n\n\n\t\t\t\t\t\Terimakasih telah menggunakan program ini :D \n\n"); printf("\t\t\t\t\t\tCreated By Sulton Ibrahim\n\n"); printf("\t\t\t\t\t\t\ NIM 1512618078\n"); sleep(3); }

5

4. Program Deret Genap Ascending

Source code: #include <stdio.h> #include #include <windows.h> #include <stdlib.h> #include main () { int e,f,g,h; e=2; g=h=0; system ("color 0A"); printf("Bilangan Bulat Genap:2,4,6,8,10,12.....\n\n"); printf("Masukan jumlah suku yang akan dicetak : ");

6

scanf("%i",&h); printf("\n"); printf("________________________________________________________ ________________________________________________________________\n\n" ); for (f=1;f<=h;f++) { printf ("%i\t",e); g=g+e; e=e+2; } printf("\n"); printf("________________________________________________________ ________________________________________________________________\n\n" ); printf("\nJumlah Deret = %i\n\n\n",g); getch(); system ("cls"); printf("\n\n\n\t\t\t\t\t\Terimakasih telah menggunakan program ini :D \n\n"); printf("\t\t\t\t\t\tCreated By Sulton Ibrahim\n\n"); printf("\t\t\t\t\t\t\ NIM 1512618078\n"); sleep(3); }

7

5. Program Deret Ganjil Pangkat Dua

Source code : #include <stdio.h> #include #include <windows.h> #include <stdlib.h> #include main () { int i,j,k,l,m; i=1; l=m=0; system ("color 0A"); printf("Bilangan Bulat:1,9,25,49,81,121,169,225.....\n\n"); printf("Masukan jumlah suku yang akan dicetak : "); scanf("%i",&m); printf("\n");

8

printf("________________________________________________________ ________________________________________________________________\n\n" ); for (j=1;j<=m;j++) { k=i*i; printf ("%i\t",k); l=l+k; i=i+2; } printf("\n"); printf("________________________________________________________ ________________________________________________________________\n\n" ); printf("\nJumlah Deret = %i\n\n\n",l); getch(); system ("cls"); printf("\n\n\n\t\t\t\t\t\Terimakasih telah menggunakan program ini :D \n\n"); printf("\t\t\t\t\t\tCreated By Sulton Ibrahim\n\n"); printf("\t\t\t\t\t\t\ NIM 1512618078\n"); sleep(3); }

9

6. Program Deret Descending Pangkat Dua

Source code: #include <stdio.h> #include #include <windows.h> #include <stdlib.h> #include main () { int n,o,p,q,r; n=2; q=r=0; system ("color 0A"); printf("Bilangan Bulat:4,16,36,64,100,144,196,256.....\n\n"); printf("Masukan jumlah suku yang akan dicetak : "); 10

scanf("%i",&r); printf("\n"); printf("________________________________________________________ ________________________________________________________________\n\n" ); for (o=1;o<=r;o++) { p=n*n; printf ("%i\t",p); q=q+p; n=n+2; } printf("\n"); printf("________________________________________________________ ________________________________________________________________\n\n" ); printf("\nJumlah Deret = %i\n\n\n",q); getch(); system ("cls"); printf("\n\n\n\t\t\t\t\t\Terimakasih telah menggunakan program ini :D \n\n"); printf("\t\t\t\t\t\tCreated By Sulton Ibrahim\n\n"); printf("\t\t\t\t\t\t\ NIM 1512618078\n"); sleep(3); }

11

7. Program Deret Ascending Pangkat Tiga

Source code: #include <stdio.h> #include #include <windows.h> #include <stdlib.h> #include main () { int s,t,u,v,w; s=10; v=w=0; system ("color 0A"); printf("Bilangan Bulat:100,81,64,49,36,25,16,9\n\n"); printf("Masukan jumlah suku yang akan dicetak : "); scanf("%i",&w); printf("\n"); 12

printf("________________________________________________________ ________________________________________________________________\n\n" ); for (t=1;t<=w;t++) { u=s*s; printf ("%i\t",u); v=v+u; s=s-1; } printf("\n"); printf("________________________________________________________ ________________________________________________________________\n\n" ); printf("\nJumlah Deret = %i\n\n\n",v); getch(); system ("cls"); printf("\n\n\n\t\t\t\t\t\Terimakasih telah menggunakan program ini :D \n\n"); printf("\t\t\t\t\t\tCreated By Sulton Ibrahim\n\n"); printf("\t\t\t\t\t\t\ NIM 1512618078\n"); sleep(3); }

13

8. Program Deret Descending Pangkat Tiga

Source code : #include <stdio.h> #include #include <windows.h> #include <stdlib.h> #include main () { int x,y,z,a1,b1; x=1; a1=b1=0; system ("color 0A"); printf("Bilangan Bulat:1,8,27,64,125.....\n\n"); printf("Masukan jumlah suku yang akan dicetak : "); scanf("%i",&b1);

14

printf("\n"); printf("________________________________________________________ ________________________________________________________________\n\n" ); for (y=1;y<=b1;y++) { z=x*x*x; printf ("%i\t",z); a1=a1+z; x=x+1; } printf("\n"); printf("________________________________________________________ ________________________________________________________________\n\n" ); printf("\nJumlah Deret = %i\n\n\n",a1); getch(); system ("cls"); printf("\n\n\n\t\t\t\t\t\Terimakasih telah menggunakan program ini :D \n\n"); printf("\t\t\t\t\t\tCreated By Sulton Ibrahim\n\n"); printf("\t\t\t\t\t\t\ NIM 1512618078\n"); sleep(3); }

15

9. Program Deret Pangkat 3 Berlanjut

Source code : #include <stdio.h> #include #include <windows.h> #include <stdlib.h> #include main () { int c1,d1,e1,f1,g1; c1=10; f1=g1=0; system ("color 0A"); printf("Bilangan Bulat:100,729,512,343.....\n\n"); printf("Masukan jumlah suku yang akan dicetak : "); scanf("%i",&g1); printf("\n");

16

printf("________________________________________________________ ________________________________________________________________\n\n" ); for (d1=1;d1<=g1;d1++) { e1=c1*c1*c1; printf ("%i\t",e1); f1=f1+e1; c1=c1-1; } printf("\n"); printf("________________________________________________________ ________________________________________________________________\n\n" ); printf("\nJumlah Deret = %i\n\n\n",f1); getch(); system ("cls"); printf("\n\n\n\t\t\t\t\t\Terimakasih telah menggunakan program ini :D \n\n"); printf("\t\t\t\t\t\tCreated By Sulton Ibrahim\n\n"); printf("\t\t\t\t\t\t\ NIM 1512618078\n"); sleep(3); }

17

10. Program Deret Ascending Pertambahan 5

Source code : #include <stdio.h> #include #include <windows.h> #include <stdlib.h> #include main () { int h1,i1,j1,k1; h1=2; j1=k1=0; system ("color 0A"); printf("Bilangan Bulat:2,4,16,256\n\n"); printf("Masukan jumlah suku yang akan dicetak : "); scanf("%i",&k1);

18

printf("\n"); printf("________________________________________________________ ________________________________________________________________\n\n" ); if (k1<=4) { for (i1=1;i1<=k1;i1++) { printf ("%i\t",h1); j1=j1+h1; h1=h1*h1; } } else printf("Tidak bisa mencetak lebih dari 4 suku"); { printf("\n"); printf("________________________________________________________ ________________________________________________________________\n\n" ); printf("\nJumlah Deret = %i\n\n\n",j1); getch(); } system ("cls"); printf("\n\n\n\t\t\t\t\t\Terimakasih telah menggunakan program ini :D \n\n"); printf("\t\t\t\t\t\tCreated By Sulton Ibrahim\n\n"); printf("\t\t\t\t\t\t\ NIM 1512618078\n"); sleep(3); }

19

11. Program Deret Bilangan Segitiga

Source code: #include <stdio.h> #include #include <windows.h> #include <stdlib.h> #include main () { int l1,m1,n1,o1; l1=2; n1=o1=0; system ("color 0A"); printf("Bilangan Bulat:2,8,512\n\n");

20

printf("Masukan jumlah suku yang akan dicetak : "); scanf("%i",&o1); printf("\n"); printf("________________________________________________________ ________________________________________________________________\n\n" ); if (o1<=4) { for (m1=1;m1<=o1;m1++) { printf ("%i\t",l1); n1=n1+l1; l1=l1*l1*l1; } } else printf("Tidak bisa mencetak lebih dari 4 suku"); { printf("\n"); printf("________________________________________________________ ________________________________________________________________\n\n" ); printf("\nJumlah Deret = %i\n\n\n",n1); getch(); } system ("cls"); printf("\n\n\n\t\t\t\t\t\Terimakasih telah menggunakan program ini :D \n\n"); printf("\t\t\t\t\t\tCreated By Sulton Ibrahim\n\n"); printf("\t\t\t\t\t\t\ NIM 1512618078\n"); sleep(3); }

21

12. Program Deret Bilangan Dikalikan 3

Source code: #include <stdio.h> #include #include <windows.h> #include <stdlib.h> #include main () { int p1,q1,r1,s1; p1=1; r1=s1=0; system ("color 0A"); printf("Bilangan Bulat:1,6,11,16,21,26.....\n\n"); printf("Masukan jumlah suku yang akan dicetak : "); scanf("%i",&s1); printf("\n");

22

printf("________________________________________________________ ________________________________________________________________\n\n" ); for (q1=1;q1<=s1;q1++) { printf ("%i\t",p1); r1=r1+p1; p1=p1+5; } printf("\n"); printf("________________________________________________________ ________________________________________________________________\n\n" ); printf("\nJumlah Deret = %i\n\n\n",r1); getch(); system ("cls"); printf("\n\n\n\t\t\t\t\t\Terimakasih telah menggunakan program ini :D \n\n"); printf("\t\t\t\t\t\tCreated By Sulton Ibrahim\n\n"); printf("\t\t\t\t\t\t\ NIM 1512618078\n"); sleep(3); }

23

13. Program Deret Bilangan Pertambahan 6

Source code: #include <stdio.h> #include #include <windows.h> #include <stdlib.h> #include main () { int t1,u1,v1,w1,x1; t1=1; v1=0; w1=x1=0; system ("color 0A"); printf("Bilangan Bulat:1,2,4,7,11,16.....\n\n"); printf("Masukan jumlah suku yang akan dicetak : "); scanf("%i",&x1);

24

printf("\n"); printf("________________________________________________________ ________________________________________________________________\n\n" ); for (u1=1;u1<=x1;u1++) { printf ("%i\t",t1); w1=w1+t1; v1=v1+1; t1=t1+v1; } printf("\n"); printf("________________________________________________________ ________________________________________________________________\n\n" ); printf("\nJumlah Deret = %i\n\n\n",w1); getch(); system ("cls"); printf("\n\n\n\t\t\t\t\t\Terimakasih telah menggunakan program ini :D \n\n"); printf("\t\t\t\t\t\tCreated By Sulton Ibrahim\n\n"); printf("\t\t\t\t\t\t\ NIM 1512618078\n"); sleep(3); }

25

14. Program Deret Bergoyang 2 (Bilangan Ganjil Pangkat Tiga & Bilangan Genap)

Source code: #include <stdio.h> #include #include <windows.h> #include <stdlib.h> #include main () { int y1,z1,a2,b2; y1=1; a2=b2=0; system ("color 0A"); printf("Bilangan Bulat:1,3,9,27,81,273.....\n\n"); printf("Masukan jumlah suku yang akan dicetak : "); scanf("%i",&b2);

26

printf("\n"); printf("________________________________________________________ ________________________________________________________________\n\n" ); for (z1=1;z1<=b2;z1++) { printf ("%i\t",y1); a2=a2+y1; y1=y1*3; } printf("\n"); printf("________________________________________________________ ________________________________________________________________\n\n" ); printf("\nJumlah Deret = %i\n\n\n",a2); getch(); system ("cls"); printf("\n\n\n\t\t\t\t\t\Terimakasih telah menggunakan program ini :D \n\n"); printf("\t\t\t\t\t\tCreated By Sulton Ibrahim\n\n"); printf("\t\t\t\t\t\t\ NIM 1512618078\n"); sleep(3); }

27

15. Program Deret Bergoyang 2 (Bilangan Descending Pengurangan 5 & Bilangan Ascending Pertambahan 6)

Source code: #include <stdio.h> #include #include <windows.h> #include <stdlib.h> #include main () { int c2,d2,e2,f2; c2=3; e2=f2=0; system ("color 0A"); printf("Bilangan Bulat:3,9,15,21,27,33,39,45.....\n\n"); printf("Masukan jumlah suku yang akan dicetak : "); scanf("%i",&f2);

28

printf("\n"); printf("________________________________________________________ ________________________________________________________________\n\n" ); for (d2=1;d2<=f2;d2++) { printf ("%i\t",c2); e2=e2+c2; c2=c2+6; } printf("\n"); printf("________________________________________________________ ________________________________________________________________\n\n" ); printf("\nJumlah Deret = %i\n\n\n",e2); getch(); system ("cls"); printf("\n\n\n\t\t\t\t\t\Terimakasih telah menggunakan program ini :D \n\n"); printf("\t\t\t\t\t\tCreated By Sulton Ibrahim\n\n"); printf("\t\t\t\t\t\t\ NIM 1512618078\n"); sleep(3); }

29

16. Program Deret Fibonanci

Source code: #include <stdio.h> #include #include <windows.h> #include <stdlib.h> #include main () { int g2,h2,i2,j2,k2,l2; g2=1; i2=2; k2=l2=0; system ("color 0A"); printf("Bilangan Bulat:1,2,27,4,125,6,343,8.....\n\n"); printf("Masukan jumlah suku yang akan dicetak : "); scanf("%i",&l2);

30

printf("\n"); printf("________________________________________________________ ________________________________________________________________\n\n" ); for (h2=1;h2<=l2;h2++) while (g2<=h2) { j2=g2*g2*g2; printf ("%i\t%i\t",j2,i2); k2=k2+j2+i2; i2=i2+2; g2=g2+2; } printf("\n"); printf("________________________________________________________ ________________________________________________________________\n\n" ); printf("\nJumlah Deret = %i\n\n\n",k2); getch(); system ("cls"); printf("\n\n\n\t\t\t\t\t\Terimakasih telah menggunakan program ini :D \n\n"); printf("\t\t\t\t\t\tCreated By Sulton Ibrahim\n\n"); printf("\t\t\t\t\t\t\ NIM 1512618078\n"); sleep(3); }

31

17. Program Deret Bergoyang 2 (Bilangan Pertambahan 1 & Bilangan Persegi)

Source code: #include <stdio.h> #include #include <windows.h> #include <stdlib.h> #include main () { int m2,n2,o2,p2,q2,r2; m2=100; o2=3; p2=q2=0; system ("color 0A"); printf("Bilangan Bulat:100,3,95,9,90,15,85,21.....\n\n"); printf("Masukan jumlah suku yang akan dicetak : "); scanf("%i",&q2);

32

r2=q2/2; printf("\n"); printf("________________________________________________________ ________________________________________________________________\n\n" ); if (q2%2==0) { r2=q2/2; for (n2=1;n2<=r2;n2++) { printf ("%i\t%i\t",m2,o2); p2=p2+m2+o2; m2=m2-5; o2=o2+6; } printf("\n"); printf("________________________________________________________ ________________________________________________________________\n\n" ); printf("\nJumlah Deret = %i\n\n\n",p2); } else { r2=q2/2; for (n2=1;n2<=r2;n2++) { printf ("%i\t%i\t",m2,o2); p2=p2+m2+o2; m2=m2-5; o2=o2+6; } printf("%i\t",m2); p2=p2+m2; printf("\n"); printf("________________________________________________________ ________________________________________________________________\n\n" ); printf("\nJumlah Deret = %i\n\n\n",p2); } getch(); system ("cls"); printf("\n\n\n\t\t\t\t\t\Terimakasih telah menggunakan program ini :D \n\n"); printf("\t\t\t\t\t\tCreated By Sulton Ibrahim\n\n"); printf("\t\t\t\t\t\t\ NIM 1512618078\n"); sleep(3); }

33

18. Program Deret Fibonacci

Source code: #include <stdio.h> #include #include <windows.h> #include <stdlib.h> #include main () { int s2,t2,u2,v2,w2,x2,y2; s2=0; u2=1; v2=w2=0; system ("color 0A"); printf("Bilangan Bulat Fibonachi:0,1,1,2,3,5,8,13.....\n\n"); printf("Masukan jumlah suku yang akan dicetak : "); scanf ("%d",&v2);

34

x2=x2+s2+t2; y2=y2+2; v2=v2-3; printf("\n"); printf("________________________________________________________ ________________________________________________________________\n\n" ); printf ("%i\t%i\t",s2,t2); for (w2=0;w2<=v2;w2++) { u2=s2+t2; printf ("\t%d\t",u2); x2=x2+u2; y2=y2+1; s2=t2; t2=u2; } printf("\n"); printf("________________________________________________________ ________________________________________________________________\n\n" ); printf("\nJumlah Deret = %i\n\n\n",x2); getch(); system ("cls"); printf("\n\n\n\t\t\t\t\t\Terimakasih telah menggunakan program ini :D \n\n"); printf("\t\t\t\t\t\tCreated By Sulton Ibrahim\n\n"); printf("\t\t\t\t\t\t\ NIM 1512618078\n"); sleep(3); }

35

19. Program Deret Bergoyang 2 (Bilangan Pangkat 2 & Bilangan Pertambahan 2)

Source code: #include <stdio.h> #include #include <windows.h> #include <stdlib.h> #include main () { int z2,a3,b3,c3,d3,e3,f3; z2=1; b3=1; c3=d3=0; system ("color 0A"); printf("Bilangan Bulat:1,1,2,4,3,9,4,16.....\n\n"); printf("Masukan jumlah suku yang akan dicetak : "); scanf("%i",&d3);

36

e3=d3/2; printf("\n"); printf("________________________________________________________ ________________________________________________________________\n\n" ); if (d3%2==0) { e3=d3/2; for (a3=1;a3<=e3;a3++) { f3=b3*b3; printf ("%i\t%i\t",z2,f3); c3=c3+z2+b3; z2=z2+1; b3=b3+1; } printf("\n"); printf("________________________________________________________ ________________________________________________________________\n\n" ); printf("\nJumlah Deret = %i\n\n\n",c3); } else { e3=d3/2; for (a3=1;a3<=e3;a3++) { f3=b3*b3; printf ("%i\t%i\t",z2,b3); c3=c3+z2+b3; z2=z2+1; b3=b3+1; } printf("%i\t",z2); c3=c3+z2; printf("\n"); printf("________________________________________________________ ________________________________________________________________\n\n" ); printf("\nJumlah Deret = %i\n\n\n",c3); } getch(); system ("cls"); printf("\n\n\n\t\t\t\t\t\Terimakasih telah menggunakan program ini :D \n\n"); printf("\t\t\t\t\t\tCreated By Sulton Ibrahim\n\n");

37

printf("\t\t\t\t\t\t\ sleep(3);\

NIM 1512618078\n");

}

38

20. Program Deret Bergoyang 2 (Bilangan Ascending & Descending Pangkat 3)

Source code: #include <stdio.h> #include #include <windows.h> #include <stdlib.h> #include main () { int g3,h3,i3,j3,k3,l3,m3; g3=1; i3=1; j3=k3=0; system ("color 0A"); printf("Bilangan Bulat:1,1,3,8,5,27,7,64,9.....\n\n"); printf("Masukan jumlah suku yang akan dicetak : "); scanf("%i",&k3);

39

l3=k3/2; printf("\n"); printf("________________________________________________________ ________________________________________________________________\n\n" ); if (k3%2==0) { l3=k3/2; for (h3=1;h3<=l3;h3++) { m3=i3*i3*i3; printf ("%i\t%i\t",g3,m3); j3=j3+g3+m3; g3=g3+2; i3=i3+1; } printf("\n"); printf("________________________________________________________ ________________________________________________________________\n\n" ); printf("\nJumlah Deret = %i\n\n\n",j3); } else { l3=k3/2; for (h3=1;h3<=l3;h3++) { m3=i3*i3*i3; printf ("%i\t%i\t",g3,m3); j3=j3+g3+m3; g3=g3+2; i3=i3+1; } printf("%i\t",g3); j3=j3+g3; printf("\n"); printf("________________________________________________________ ________________________________________________________________\n\n" ); printf("\nJumlah Deret = %i\n\n\n",j3); } getch(); system ("cls"); printf("\n\n\n\t\t\t\t\t\Terimakasih telah menggunakan program ini :D \n\n"); printf("\t\t\t\t\t\tCreated By Sulton Ibrahim\n\n");

40

printf("\t\t\t\t\t\t\ sleep(3);

NIM 1512618078\n");

}

41

21. Program Deret Bergoyang 2 (Dua Bilangan Pertambahan 3)

Source code: #include <stdio.h> #include #include <windows.h> #include <stdlib.h> #include main () { int n3,o3,p3,q3,r3,s3,t3; n3=1; p3=2; q3=r3=0; system ("color 0A"); printf("Bilangan Bulat:1,2,4,4,9,6,16,8.....\n\n"); printf("Masukan jumlah suku yang akan dicetak : "); scanf("%i",&r3);

42

s3=r3/2; printf("\n"); printf("________________________________________________________ ________________________________________________________________\n\n" ); if (r3%2==0) { s3=r3/2; for (o3=1;o3<=s3;o3++) { t3=n3*n3; printf ("%i\t%i\t",t3,p3); q3=q3+n3+t3; n3=n3+1; p3=p3+2; } printf("\n"); printf("________________________________________________________ ________________________________________________________________\n\n" ); printf("\nJumlah Deret = %i\n\n\n",q3); } else { s3=r3/2; for (o3=1;o3<=s3;o3++) { t3=n3*n3; printf ("%i\t%i\t",t3,p3); q3=q3+n3+t3; n3=n3+1; p3=p3+2; } printf("%i\t",n3); q3=q3+n3; printf("\n"); printf("________________________________________________________ ________________________________________________________________\n\n" ); printf("\nJumlah Deret = %i\n\n\n",q3); } getch(); system ("cls"); printf("\n\n\n\t\t\t\t\t\Terimakasih telah menggunakan program ini :D \n\n"); printf("\t\t\t\t\t\tCreated By Sulton Ibrahim\n\n");

43

printf("\t\t\t\t\t\t\ sleep(3);

NIM 1512618078\n");

}

44

22. Program Deret Bergoyang 2 (Bilangan Pangkat 3 & Bilangan Pertambahan 7)

Source code: #include <stdio.h> #include #include <windows.h> #include <stdlib.h> #include main () { int u3,v3,w3,x3,y3,z3,a4,b4; u3=1; w3=10; x3=y3=0; system ("color 0A"); printf("Bilangan Bulat:1,1000,8,729,27,512,64,343.....\n\n"); printf("Masukan jumlah suku yang akan dicetak : "); scanf("%i",&y3);

45

z3=y3/2; printf("\n"); printf("________________________________________________________ ________________________________________________________________\n\n" ); if (y3%2==0) { z3=y3/2; for (v3=1;v3<=z3;v3++) { a4=u3*u3*u3; b4=w3*w3*w3; printf ("%i\t%i\t",a4,b4); x3=x3+a4+b4; u3=u3+1; w3=w3-1; } printf("\n"); printf("________________________________________________________ ________________________________________________________________\n\n" ); printf("\nJumlah Deret = %i\n\n\n",x3); } else { z3=y3/2; for (v3=1;v3<=z3;v3++) { a4=u3*u3*u3; b4=w3*w3*w3; printf ("%i\t%i\t",a4,b4); x3=x3+a4+b4; u3=u3+1; w3=w3-1; } printf("%i\t",u3); x3=x3+u3; printf("\n"); printf("________________________________________________________ ________________________________________________________________\n\n" ); printf("\nJumlah Deret = %i\n\n\n",x3); } getch(); system ("cls");

46

printf("\n\n\n\t\t\t\t\t\Terimakasih telah menggunakan program ini :D \n\n"); printf("\t\t\t\t\t\tCreated By Sulton Ibrahim\n\n"); printf("\t\t\t\t\t\t\ NIM 1512618078\n"); sleep(3); }

47

23. Program Deret Bergoyang 2 (Bilangan Pertambahan 10 & Bilangan Pertambahan 5)

Source code: #include <stdio.h> #include #include <windows.h> #include <stdlib.h> #include main () { int c4,d4,e4,f4,g4,h4; c4=2; e4=3; f4=g4=0; system ("color 0A"); printf("Bilangan Bulat:2,3,5,6,8,9,11.....\n\n"); printf("Masukan jumlah suku yang akan dicetak : ");

48

scanf("%i",&g4); h4=g4/2; printf("\n"); printf("________________________________________________________ ________________________________________________________________\n\n" ); if (g4%2==0) { h4=g4/2; for (d4=1;d4<=h4;d4++) { printf ("%i\t%i\t",c4,e4); f4=f4+c4+e4; c4=c4+3; e4=e4+3; } printf("\n"); printf("________________________________________________________ ________________________________________________________________\n\n" ); printf("\nJumlah Deret = %i\n\n\n",f4); } else { h4=g4/2; for (d4=1;d4<=h4;d4++) { printf ("%i\t%i\t",c4,e4); f4=f4+c4+e4; c4=c4+3; e4=e4+3; } printf("%i\t",c4); f4=f4+c4; printf("\n"); printf("________________________________________________________ ________________________________________________________________\n\n" ); printf("\nJumlah Deret = %i\n\n\n",f4); } getch(); system ("cls"); printf("\n\n\n\t\t\t\t\t\Terimakasih telah menggunakan program ini :D \n\n"); printf("\t\t\t\t\t\tCreated By Sulton Ibrahim\n\n"); printf("\t\t\t\t\t\t\ NIM 1512618078\n");

49

sleep(3); }

50

24. Program Deret Bergoyang 2 (Bilangan Pengurangan 3 & Bilangan Pengurangan 2)

Source code: #include <stdio.h> #include #include <windows.h> #include <stdlib.h> #include main () { int i4,j4,k4,l4,m4,n4,o4; i4=1; k4=7; l4=m4=0; system ("color 0A"); printf("Bilangan Bulat:1,7,8,14,27,21,64,28,125,35.....\n\n");

51

printf("Masukan jumlah suku yang akan dicetak : "); scanf("%i",&m4); n4=m4/2; printf("\n"); printf("________________________________________________________ ________________________________________________________________\n\n" ); if (m4%2==0) { n4=m4/2; for (j4=1;j4<=n4;j4++) { o4=i4*i4*i4; printf ("%i\t%i\t",o4,k4); l4=l4+o4+k4; i4=i4+1; k4=k4+7; } printf("\n"); printf("________________________________________________________ ________________________________________________________________\n\n" ); printf("\nJumlah Deret = %i\n\n\n",l4); } else { n4=m4/2; for (j4=1;j4<=n4;j4++) { o4=i4*i4*i4; printf ("%i\t%i\t",o4,k4); l4=l4+o4+k4; i4=i4+1; k4=k4+7; } printf("%i\t",i4); l4=l4+i4; printf("\n"); printf("________________________________________________________ ________________________________________________________________\n\n" ); printf("\nJumlah Deret = %i\n\n\n",l4); } getch(); system ("cls");

52

printf("\n\n\n\t\t\t\t\t\Terimakasih telah menggunakan program ini :D \n\n"); printf("\t\t\t\t\t\tCreated By Sulton Ibrahim\n\n"); printf("\t\t\t\t\t\t\ NIM 1512618078\n"); sleep(3); }

53

25. Program Deret Bergoyang 2 (Bilangan Pertambahan 2 & Bilangan Pengurangan 2)

Source code: #include <stdio.h> #include #include <windows.h> #include <stdlib.h> #include main () { int p4,q4,r4,s4,t4,u4; p4=1; r4=5; s4=t4=0; system ("color 0A"); printf("Bilangan Bulat:1,5,11,10,21,15,31,20,41,25,51.....\n\n"); printf("Masukan jumlah suku yang akan dicetak : ");

54

scanf("%i",&t4); u4=t4/2; printf("\n"); printf("________________________________________________________ ________________________________________________________________\n\n" ); if (t4%2==0) { u4=t4/2; for (q4=1;q4<=u4;q4++) { printf ("%i\t%i\t",p4,r4); s4=s4+p4+r4; p4=p4+10; r4=r4+5; } printf("\n"); printf("________________________________________________________ ________________________________________________________________\n\n" ); printf("\nJumlah Deret = %i\n\n\n",s4); } else { u4=t4/2; for (q4=1;q4<=u4;q4++) { printf ("%i\t%i\t",p4,r4); s4=s4+p4+r4; p4=p4+10; r4=r4+5; } printf("%i\t",p4); s4=s4+p4; printf("\n"); printf("________________________________________________________ ________________________________________________________________\n\n" ); printf("\nJumlah Deret = %i\n\n\n",s4); } getch(); system ("cls"); printf("\n\n\n\t\t\t\t\t\Terimakasih telah menggunakan program ini :D \n\n"); printf("\t\t\t\t\t\tCreated By Sulton Ibrahim\n\n"); printf("\t\t\t\t\t\t\ NIM 1512618078\n");

55

sleep(3); }

56

26. Program Deret Bergoyang 2 (Bilangan Pertambahan Kelipatan 2)

Source code: #include <stdio.h> #include #include <windows.h> #include <stdlib.h> #include main () { int v4,w4,x4,y4,z4,a5; v4=15; x4=13; y4=z4=0; system ("color 0A"); printf("Bilangan Bulat:15,13,12,11,9,9,6,7.....\n\n"); printf("Masukan jumlah suku yang akan dicetak : "); scanf("%i",&z4);

57

a5=z4/2; printf("\n"); printf("________________________________________________________ ________________________________________________________________\n\n" ); if (z4%2==0) { a5=z4/2; for (w4=1;w4<=a5;w4++) { printf ("%i\t%i\t",v4,x4); y4=y4+v4+x4; v4=v4-3; x4=x4-2; } printf("\n"); printf("________________________________________________________ ________________________________________________________________\n\n" ); printf("\nJumlah Deret = %i\n\n\n",y4); } else { a5=z4/2; for (w4=1;w4<=a5;w4++) { printf ("%i\t%i\t",v4,x4); y4=y4+v4+x4; v4=v4-3; x4=x4-2; } printf("%i\t",v4); y4=y4+v4; printf("\n"); printf("________________________________________________________ ________________________________________________________________\n\n" ); printf("\nJumlah Deret = %i\n\n\n",y4); } getch(); system ("cls"); printf("\n\n\n\t\t\t\t\t\Terimakasih telah menggunakan program ini :D \n\n"); printf("\t\t\t\t\t\tCreated By Sulton Ibrahim\n\n"); printf("\t\t\t\t\t\t\ NIM 1512618078\n"); sleep(3); }

58

27. Program Deret Bergoyang 2 (Bilangan Pertambahan Kelipatan 2)

Source code: #include <stdio.h> #include #include <windows.h> #include <stdlib.h> #include main () { int i5,j5,k5,l5,m5,n5; i5=2; k5=10; l5=m5=0; system ("color 0A"); printf("Bilangan Bulat:2,10,4,8,6,6,8,4.....\n\n"); printf("Masukan jumlah suku yang akan dicetak : ");

59

scanf("%i",&m5); n5=m5/2; printf("\n"); printf("________________________________________________________ ________________________________________________________________\n\n" ); if (m5%2==0) { n5=m5/2; for (j5=1;j5<=n5;j5++) { printf ("%i\t%i\t",i5,k5); l5=l5+i5+k5; i5=i5+2; k5=k5-2; } printf("\n"); printf("________________________________________________________ ________________________________________________________________\n\n" ); printf("\nJumlah Deret = %i\n\n\n",l5); } else { n5=m5/2; for (j5=1;j5<=n5;j5++) { printf ("%i\t%i\t",i5,k5); l5=l5+i5+k5; i5=i5+2; k5=k5-2; } printf("%i\t",i5); l5=l5+i5; printf("\n"); printf("________________________________________________________ ________________________________________________________________\n\n" ); printf("\nJumlah Deret = %i\n\n\n",l5); } getch(); system ("cls"); printf("\n\n\n\t\t\t\t\t\Terimakasih telah menggunakan program ini :D \n\n"); printf("\t\t\t\t\t\tCreated By Sulton Ibrahim\n\n");

60

printf("\t\t\t\t\t\t\ sleep(3);

NIM 1512618078\n");

}

61

28. Program Deret Bergoyang 3 (Bilangan Pertambahan 5)

Source code: #include <stdio.h> #include #include <windows.h> #include <stdlib.h> #include main () { int v5,w5,x5,y5,z5,a6,b6; v5=2; x5=3; b6=2; y5=z5=0; system ("color 0A"); printf("Bilangan Bulat:2,3,6,7,14,15,30,31.....\n\n");

62

printf("Masukan jumlah suku yang akan dicetak : "); scanf("%i",&z5); a6=z5/2; printf("\n"); printf("________________________________________________________ ________________________________________________________________\n\n" ); if (z5%2==0) { a6=z5/2; for (w5=1;w5<=a6;w5++) { printf ("%i\t%i\t",v5,x5); y5=y5+v5+x5; b6=b6*2; v5=v5+b6; x5=x5+b6; } printf("\n"); printf("________________________________________________________ ________________________________________________________________\n\n" ); printf("\nJumlah Deret = %i\n\n\n",y5); } else { a6=z5/2; for (w5=1;w5<=a6;w5++) { printf ("%i\t%i\t",v5,x5); b6=b6*2; y5=y5+v5+x5; v5=v5+b6; x5=x5+b6; } printf("%i\t",v5); y5=y5+v5; printf("\n"); printf("________________________________________________________ ________________________________________________________________\n\n" ); printf("\nJumlah Deret = %i\n\n\n",y5); } getch(); system ("cls");

63

printf("\n\n\n\t\t\t\t\t\Terimakasih telah menggunakan program ini :D \n\n"); printf("\t\t\t\t\t\tCreated By Sulton Ibrahim\n\n"); printf("\t\t\t\t\t\t\ NIM 1512618078\n"); sleep(3); }

64

29. Program Deret Bergoyang 2 (Bilangan Pertambahan Kelipatan 2)

Source Code: #include <stdio.h> #include #include <windows.h> #include <stdlib.h> #include main () { int b5,c5,d5,e5,f5,g5,h5; b5=18; d5=10;

65

h5=2; e5=f5=0; system ("color 0A"); printf("Bilangan Bulat:18,10,20,12,24,16,32,24,48.....\n\n"); printf("Masukan jumlah suku yang akan dicetak : "); scanf("%i",&f5); g5=f5/2; printf("\n"); printf("______________________________________________________________ __________________________________________________________\n\n"); if (f5%2==0) { g5=f5/2; for (c5=1;c5<=g5;c5++) { printf ("%i\t%i\t",b5,d5); e5=e5+b5+d5; b5=b5+h5; d5=d5+h5; h5=h5*2; } printf("\n"); printf("______________________________________________________________ __________________________________________________________\n\n"); printf("\nJumlah Deret = %i\n\n\n",e5); } else { g5=f5/2; for (c5=1;c5<=g5;c5++) { h5=h5*2; printf ("%i\t%i\t",b5,d5); e5=e5+b5+d5;

66

b5=b5+h5; d5=d5+h5; h5=h5*2; } printf("%i\t",b5); e5=e5+b5; printf("\n"); printf("______________________________________________________________ __________________________________________________________\n\n"); printf("\nJumlah Deret = %i\n\n\n",e5); } getch(); c }

67

30. Program Deret Bergoyang 3 (Bilangan Pertambahan 5)

Source Code: #include <stdio.h> #include #include <windows.h> #include <stdlib.h> #include main () { int o5,p5,q5,r5,s5,t5,u5; o5=1;

68

q5=2; u5=3; r5=s5=0; system ("color 0A"); printf("Bilangan Bulat:1,2,3,6,7,8,11,12,13,16,17,18.....\n\n"); printf("Masukan jumlah suku yang akan dicetak : "); scanf("%i",&s5); t5=s5/2; printf("\n"); printf("______________________________________________________________ __________________________________________________________\n\n"); if (s5%2==0) { t5=s5/2; for (p5=1;p5<=t5;p5++) { printf ("%i\t%i\t%i\t",o5,q5,u5); r5=r5+o5+q5+u5; o5=o5+5; q5=q5+5; u5=u5+5; } printf("\n"); printf("______________________________________________________________ __________________________________________________________\n\n"); printf("\nJumlah Deret = %i\n\n\n",r5); } else { t5=s5/2; for (p5=1;p5<=t5;p5++) { printf ("%i\t%i\t%i\t",o5,q5,u5); r5=r5+o5+q5+u5;

69

o5=o5+5; q5=q5+5; u5=u5+5;

} printf("%i\t",o5); r5=r5+o5; printf("\n"); printf("______________________________________________________________ __________________________________________________________\n\n"); printf("\nJumlah Deret = %i\n\n\n",r5); } getch(); system ("cls"); printf("\n\n\n\t\t\t\t\t\Terimakasih telah menggunakan program ini :D \n\n"); printf("\t\t\t\t\t\tCreated By Sulton Ibrahim\n\n"); printf("\t\t\t\t\t\t\

NIM 1512618078\n");

sleep(3);

}

70

B. Program Kreasi 1. Program Pengecekan Kenormalan Denyut Nadi

Setelah menginput denyut nadi akan keluar hasilnya seperti berikut Source code: #include <stdio.h> #include #include <windows.h> #include <stdlib.h> int main() { printf("\t\t\t\t\t============================================\ n"); printf("\t\t\t\t\t|Program Pengecekan Kenormalan Denyut Nadi |\n"); printf("\t\t\t\t\t============================================\ n\n\n"); int detak ; printf("Hitung denyut nadi dengan meletakkan ujung jari telunjuk dan jari tengah pada pangkal ibu jari di \n"); printf("pergelangan tangan atau sisi batang tengorokan selama 15 detik\n\n\n"); printf ("Ketik detak yang sudah di hitung = \n\n"); scanf ("%d", &detak); if (detak >80) printf("\nDiatas rata-rata orang normal"); else if (detak >=50) printf("\nNormal"); else if (detak >=0) printf("\nDibawah rata rata orang normal"); else printf("\nError, coba cek nilai yang anda input"); getch (); }

71

2. Program Hompimpa Tampilan awal program

Setelah mengetik key apa saja

Jika anda menang melawan CPU akan menjadi seperti ini

72

Jika kalah akan seperti ini

Dan seri akan menjadi seperti ini

73

Setelah kalah 3 kali kalah game akan berakhir

Source code: #include<stdio.h> #include<stdlib.h>

void opening ()//menu awal mulai game { printf("\n\n\n\t\t====================================\n"); printf("\t\t\tSELAMAT DATANG di GAME\n"); printf("\t\t\t HOMPIMPA\n"); printf("\t\t Gunting || Kertas || Batu\n"); printf("\t\t====================================\n"); system("pause"); } main () { int player;//variabel untuk menyatakan angka yang kita input int cpu;//variabel untuk menyatakan angka yang dikeluarkan oleh CPU int kalah=0;//variabel untuk menangpung nilai kalah di mulai dari 0 int menang=0;//variabel untuk menangpung nilai menang di mulai dari 0 int seri=0;//variabel untuk menangpung nilai seri di mulai dari 0 system("title GAME HOMPIMPA");//untuk mengubah nama judul console,kalau tidak diganti maka nama akan menjadi tempat lokasi penyimpanan codingan opening();//menampilkan void opening while(kalah<3)//kesempatan player bermain hanya 3x { system("CLS");//untuk mengosongkan layar cpu=rand()%3;//angka yang dikeluarkan oleh CPU dirandom mulai dari angka 0 sampai 3

74

printf("\t (pilihlah sesuai yang ada pada pilihan)\n"); printf("\n\tGame Gunting Kertas Batu ");printf("\t\t\t\t\t%d=",3kalah);putchar(3);//menampilakn jumlah nyawa, dan putcher menampilkan kode ascii 3 printf("\n"); printf("\t\t0. Gunting\n"); printf("\t\t1. Kertas\n"); printf("\t\t2. Batu\n"); printf("\tMana yang ingin Anda Pilih ? "); scanf("%d",&player);//player menginput angka yang dipilihnya if(player==0)//kondisi jika player memilih gunting { switch(cpu) { case 0: system("CLS"); printf("\n\n"); printf("\t ANDA vs CPU \n"); printf("\tGUNTING =><= GUNTING\n"); printf("\n\tHasilnya = SERI\n"); seri=seri+1;//setiap player seri maka nilai 1 di tampung dalam variabel seri break; case 1: system("CLS"); printf("\n\n"); printf("\t ANDA vs CPU \n"); printf("\tGUNTING =><= KERTAS\n"); printf("\n\tHasilnya = ANDA MENANG ");putchar(1); printf("\n\n"); menang=menang+1;//setiap player menang maka nilai 1 di tampung dalam variabel menang break; case 2: system("CLS"); printf("\n\n"); printf("\t ANDA vs CPU \n"); printf("\tGUNTING =><= BATU\n"); printf("\n\tHASILNYA = ANDA KALAH ");putchar(2); printf("\n\n"); kalah=kalah+1;//setiap player kalah maka nilai 1 akan ditampung dalam variabel kalah break; }

75

system("pause"); } else if(player==1)//kondisi jika player memilih batu { switch(cpu) { case 0: system("CLS"); printf("\n\n"); printf("\tANDA vs CPU \n"); printf("\tBATU =><= GUNTING\n"); printf("\n\tHasilnya = ANDA MENANG ");putchar(1); printf("\n\n"); menang=menang+1;//setiap player menang maka nilai 1 akan ditampung dalam variabel kalah break; case 1: system("CLS"); printf("\n\n"); printf("\tANDA vs CPU \n"); printf("\tBATU =><= KERTAS\n"); printf("\n\tHasilnya = ANDA KALAH ");putchar(2); printf("\n\n"); kalah=kalah+1;//setiap player kalah maka nilai 1 akan ditampung dalam variabel kalah break; case 2: system("CLS"); printf("\n\n"); printf("\tANDA vs CPU \n"); printf("\tBATU =><= BATU\n"); printf("\n\tHasilnya = SERI\n "); printf("\n\n"); seri=seri+1;//setiap player seri makan nilai 1 di tampung dalam variabel seri break; } system("pause"); } else if (player==2)//kondisi jika player memilih kertas { switch(cpu) { case 0: system("CLS");

76

printf("\n\n"); printf("\tANDA vs CPU \n"); printf("\tKERTAS =><= GUNTING\n"); printf("\n\tHasilnya = ANDA KALAH ");putchar(2); printf("\n\n"); kalah=kalah+1;//setiap player kalah maka nilai 1 di tampung dalam variabel menang break; case 1: system("CLS"); printf("\n\n"); printf("\tANDA vs CPU \n"); printf("\tKERTAS =><= KERTAS\n"); printf("\n\tHasilnya = SERI "); printf("\n\n"); seri=seri+1;//setiap player seri makan nilai 1 di tampung dalam variabel seri break; case 2: system("CLS"); printf("\n\n"); printf("\tANDA vs CPU \n"); printf("\tKERTAS =><= BATU\n"); printf("\n\tHasilnya = ANDA MENANG ");putchar(1); printf("\n\n"); menang=menang+1;//setiap player menang maka nilai 1 akan ditampung dalam variabel kalah break; } system("pause"); } else { system("CLS"); printf("\tPerintah ditolak, Coba lebih Teliti ");putchar(16);putchar(17); printf("\n\n"); } } system("CLS"); printf("\n\n\t\t\tGAME OVER\n"); //player kalah sebanyak 3 kali maka game berhenti printf("\t\t============================\n"); printf("\t\t\tAnda Menang %d\n",menang);//menampilkan jumlah permainan menang, dengan menggunakan variabel yang telah menampung nilai menang printf("\t\t\tAnda Seri %d\n",seri);//menampilkan jumlah permainan seri, dengan menggunakan variabel yang telah menampung nilai seri

77

printf("\t\t\tAnda Kalah %d\n",kalah);//menampilkan jumlah permainan seri, dengan menggunakan variabel yang telah menampung nilai seri printf("\t\t============================\n"); system("pause"); }

78

3. Program Aplikasi Pengisian Pulsa Tampilan awal akan seperti ini

Pilih operator yang ingin dipilih

Input nomor yang ingin dikirimkan pulsa

79

Input jumlah pulsa yang dinginkan dan setelah di input akan langsung keluar harga yang harus dibayar

Source code: #include <stdio.h> #include <stdlib.h> #include #include #include <windows.h> int namaoperator,nomorponsel,pulsa,pembayaran; int p(int pulsa); int main (void) { do { 80

menu : printf("APLIKASI PENGISIAN PULSA\n"); printf("\nKODE OPERATOR"); printf("\n 1.Telkomsel"); printf("\n 2.INDOSAT"); printf("\n 3.XL"); printf("\n 4.SMARTFREN"); printf("\n 5.EXIT"); printf("\nMASUKAN KODE OPERATOR :"); scanf("%d",&namaoperator); switch (namaoperator) { case 1: printf("\n 1.TELKOMSEL"); printf("\n MASUKAN NOMOR PONSEL"); scanf("%d",&nomorponsel); printf("\n MASUKAN JUMLAH PULSA"); scanf("%d",&pulsa); printf("\n PEMBAYARAN PULSA = %d\n\n",p(pulsa)); break; case 2: printf("\n 2.INDOSAT"); printf("\n MASUKAN NOMOR PONSEL"); scanf("%d",&nomorponsel); printf("\n MASUKAN JUMLAH PULSA"); scanf("%d",&pulsa); printf("\n PEMBAYARAN PULSA = %d\n\n",p(pulsa)); break; case 3: printf("\n 3.XL"); printf("\n MASUKAN NOMOR PONSEL"); scanf("%d",&nomorponsel); printf("\n MASUKAN JUMLAH PULSA"); scanf("%d",&pulsa); printf("\n PEMBAYARAN PULSA = %d\n\n",p(pulsa)); break; case 4: printf("\n 4.SMARTFREN"); printf("\n MASUKAN NOMOR PONSEL"); scanf("%d",&nomorponsel); printf("\n MASUKAN JUMLAH PULSA");

81

scanf("%d",&pulsa); printf("\n PEMBAYARAN PULSA = %d\n\n",p(pulsa)); break; case 5: exit (0); default: printf("\nKODE YANG ANDA MASUKAN SALAH\n\n"); getch(); system ("cls"); goto menu; }

} while (namaoperator > 4); system ("pause"); return (0); } int p (int pulsa) { pembayaran=pulsa+2000; return (pembayaran); }

82

4. Program Puzzle Akan ditampilkan tampilan awal seperti ini

Tekan sembarang untuk melanjutkan dan akan keluar menu level kesulitan permainan puzzle

Setelah memilih akan menuju ke permainan arahkan dengan panah agar angka semua yang ada tersusun dengan benar

83

Source code: #include <stdlib.h> #include #include <stdio.h> #include #include <windows.h> #include #define atas 1 #define kiri 2 #define bawah 3 #define kanan 4 #define keyUp 0x050 #define keyDown 0x048 #define keyLeft 0x04d #define keyRight 0x04b #define true 1 #define false 0 #define easy 10 #define medium 100 #define hard 1000 #define caption "------------------------------------------------------------------------\n|\t\t\t\t GAME PUZZLE \t\t\t\t|\n------------------------------------------------------------------------\n" #define fieldSize 4

84

char field[fieldSize][fieldSize]; char field2[fieldSize][fieldSize]; unsigned int seed; int x, y; int acak(int i); void initField(int movement); void move(int arah); void generateOutput(); int cekUrut(); int acak(int i) { int a; seed += 5; srand(seed); a = (rand() % i) + 1; return(a); } void initField(int movement) { int arah, arahOld = -1, nPindah = movement, xOld, yOld; int c = 1, i, j; char temp; srand(time(NULL)); seed = rand(); x = y = (fieldSize - 1); for (i = 0; i <= (fieldSize - 1); i++) { for (j = 0; j <= (fieldSize - 1); j++) { field[i][j] = field2[i][j] = c; c++; } } field[fieldSize - 1][fieldSize - 1] = field2[fieldSize - 1][fieldSize - 1] = ' '; c = 0; while (c != nPindah) { xOld = x; yOld = y; arah = acak(4); if (arah != 0) { if ( c != 0) {

85

if ((arah + 2) % 4 == arahOld) { continue; } } switch (arah) { case atas : if (y > 0) y--; else continue; break; case kiri: if (x > 0) x--; else continue; break; case kanan : if (x < fieldSize - 1) x++; else continue; break; case bawah : if (y < fieldSize - 1) y++; else continue; break; default : break; } if (x >= 0 && y >= 0 && x <= (fieldSize - 1) && y <= (fieldSize - 1)) { temp = field[y][x]; field[y][x] = field[yOld][xOld]; field[yOld][xOld] = temp; c++; arahOld = arah % 4; } else { x = xOld; y = yOld; } } } } void move(int arah) { int xOld, yOld; char temp; xOld = x; yOld = y;

86

switch (arah) { case atas : if (y > 0) y--; break; case kiri: if (x > 0) x--; break; case kanan : if (x < (fieldSize - 1)) x++; break; case bawah : if (y < (fieldSize - 1)) y++; break; default : break; } if (x >= 0 && y >= 0 && x <= (fieldSize - 1) && y <= (fieldSize - 1)) { temp = field[y][x]; field[y][x] = field[yOld][xOld]; field[yOld][xOld] = temp; } else { x = xOld; y = yOld; } generateOutput(); } void generateOutput() { int i, j, k; system("cls"); puts(caption); puts("Tekan ESC untuk keluar / reset permainan..."); for(k = 1; k <= fieldSize; k++) printf("+----"); puts("+"); for (i = 0; i<=(fieldSize - 1); i++) { for (j= 0; j<=(fieldSize - 1); j++) { if (i == y && j == x) { printf("| %c ", field[i][j]); } else { printf("| %2i ", field[i][j]); } } puts("|"); for(k = 1; k <= fieldSize; k++) printf("+----"); puts("+"); } }

87

int cekUrut() { int c, d; int match = true; for (c = 0; c <= (fieldSize - 1); c++) { for (d = 0; d <= (fieldSize - 1); d++) { if (field[c][d] != field2[c][d]) { if (match == true) { match = false; } } } } return(match); } int main() { system("color f0"); int i, j, k, level; char key; system("cls"); puts(caption); puts("Mainkan puzzle dan menyusunnya menjadi urutan yang benar..."); puts("Geser kotak kosong sehingga menjadi berurutan sbg berikut : \n"); initField(0); for(k = 1; k <= fieldSize; k++) printf("+----"); puts("+"); for (i = 0; i<=(fieldSize - 1); i++) { for (j= 0; j<=(fieldSize - 1); j++) { if (i == y && j == x) { printf("| %c ", field2[i][j]); } else { printf("| %2i ", field2[i][j]); } } puts("|"); for(k = 1; k <= fieldSize; k++) printf("+----"); puts("+"); } puts("Gunakan tombol panah untuk menggeser kotak kosong...\n"); puts("Tekan sembarang tombol untuk melanjutkan..."); getch(); for(;;) { system("cls"); puts("Level : "); puts("\t1. Easy");

88

puts("\t2. Medium"); puts("\t3. Hard"); printf("Pilih Level yang akan dimainkan : "); scanf("%i", &level); switch (level) { case 1 : initField(easy); break; case 2 : initField(medium); break; case 3 : initField(hard); break; default : puts("Level salah!!"); getch(); continue; } system("cls"); generateOutput(); while ((key = getch()) != 27) { switch(key) { case keyUp : move(atas); break; case keyDown : move(bawah); break; case keyLeft : move(kiri); break; case keyRight : move(kanan); break; } if (cekUrut() == true) { puts("\nANDA MENANG!!!"); break; } } if (key == 27) { printf("Apakah anda ingin keluar ?\n['y' utk keluar / 't' utk reset] : "); if (toupper(getchar()) == 'Y') break;

89

else continue; } else { printf("Apakah anda ingin main lagi ? [y/t] : "); if (toupper(getchar()) == 'T') { puts("\nTerima Kasih Telah Mencoba!!!"); getch(); break; } else continue; } } }

90

5. Program Wartel Ditampilkan menu awal seperti berikut

Input kode wilayah yang sudah tersedia diatas

Setelah itu input nomor telepon yang akan dituju dan jam mulai dan berakhirnya percakapan

91

Menu 1 untuk melihat informasi percakapan

Menu 2 untuk menghitung durasi lama bicara

92

Menu 3 untuk menghitung biaya percakapan yang harus dibayar

Menu 4 untuk keluar program

93

Source code: #include <stdio.h> #include #include <windows.h> #include <stdlib.h>

main() { typedef struct { int jj; int mm; int dd; } jam; jam w1, w2, w3; int menu, i; int kode; int nomor; long int totaldetik1, totaldetik2, durasi; int lamapulsa, tarifpulsa; int pulsa, biaya;

printf ("<---------------------.::Menu Wartel::.--------------------->\n"); printf ("\nMenu 1 : Melihat informasi percakapan"); 94

printf ("\nMenu 2 : Menghitung durasi lama bicara"); printf ("\nMenu 3 : Menghitung biaya percakapan"); printf ("\nMenu 4 : Keluar\n"); printf ("\nDaftar Kode Wilayah\n"); for (i=0;i<=60;i++) { printf ("-"); } printf ("\n"); printf ("Kode\tWilayah Kota\tTarif Tiap Pulsa\tLama Pulsa\n"); for (i=0;i<=60;i++) { printf ("-"); } printf ("\n"); printf ("021\tJakarta\t\tRp 150\t\t\t1 menit"); printf ("\n0751\tPadang\t\tRp 250\t\t\t30 detik"); printf ("\n0737\tMedan\t\tRp 375\t\t\t25 detik"); printf ("\n0912\tBalikpapan\tRp 415\t\t\t20 detik"); printf ("\n0981\tTernate\t\tRp 510\t\t\t17 detik\n"); for (i=0;i<=60;i++) { printf ("-"); } printf ("\nMasukkan kode wilayah yang dituju = 0"); scanf ("%d",&kode); printf ("\nNomor Telepon tujuan = "); scanf ("%d",&nomor); printf ("\nJam mulai percakapan\n"); printf ("Jam\t= "); scanf ("%d",&w1.jj); printf ("Menit\t= "); scanf ("%d",&w1.mm); printf ("Detik\t= "); scanf ("%d",&w1.dd); printf ("\nJam akhir percakapan\n"); printf ("Jam\t= "); scanf ("%d",&w2.jj); printf ("Menit\t= "); scanf ("%d",&w2.mm); printf ("Detik\t= "); scanf ("%d",&w2.dd); do { pilih: printf ("\nPilih salah satu menu dari daftar diatas = "); scanf("%d",&menu);

95

switch (menu) { case 1 : printf ("\nNomor telepon yang anda tuju adalah 0%d - %d",kode,nomor); printf ("\nJam mulai percakapan %d : %d : %d",w1.jj,w1.mm,w1.dd); printf ("\nJam akhir percakapan %d : %d : %d",w2.jj,w2.mm,w2.dd); break; case 2 : totaldetik1 = (w1.jj*3600) + (w1.mm*60) + w1.dd; totaldetik2 = (w2.jj*3600) + (w2.mm*60) + w2.dd; durasi = totaldetik2 - totaldetik1; printf ("\nDurasi anda melakukan percakapan adalah %d detik\n",durasi); break; case 3 : if (kode == 21){lamapulsa = 60; tarifpulsa = 150;} if (kode == 751){ lamapulsa = 30; tarifpulsa = 250;} if (kode == 737){ lamapulsa = 25; tarifpulsa = 375;} if (kode == 912){ lamapulsa = 20; tarifpulsa = 415;} if (kode == 981){ lamapulsa = 17; tarifpulsa = 510;} totaldetik1 = (w1.jj*3600) + (w1.mm*60) + w1.dd; totaldetik2 = (w2.jj*3600) + (w2.mm*60) + w2.dd; durasi = totaldetik2 - totaldetik1; pulsa = durasi/ lamapulsa; biaya = pulsa*tarifpulsa; printf ("\nBiaya percakapan anda adalah Rp. %d\n",biaya); break; case 4 : printf ("\n<---------.::Terima Kasih Telah Menggunakan Jasa Layanan Kami::.--------->"); break; } } while (menu<=3); if (menu > 4) { printf ("...::Maaf anda salah memasukkan menu::..."); 96

printf ("\n<------Silahkan pilih menu kembali------>\n"); goto pilih; } getch(); }

97

More Documents from "Sulton Ibrahim"