Bahasa C

CONTOH – CONTOH PROGRAM TURBO C

1.

/* Contoh Program Menghitung Luas Lingkaran */

# include < stdio.h >

main()

{

float l,r;

clrscr();

Printf ( ” Menghitung Luas Lingkaran \n “);

Printf ( ” =========================\n “);

Printf ( ” Masukkan Nilai Jari – Jari : “);

scanf ( “%f”,&r);

l=3.14*r*r;

printf (” Luas Lingkaran = % 6.2%f”,l);

getch();

}

2.

/* Contoh Program Menghitung Luas Segitiga */

# include < stdio.h >

main()

{

float L,a,t;

clrscr();

Printf ( ” Menghitung Luas Segitiga \n “);

Printf ( ” =========================\n “);

Printf ( ” Masukkan Nilai alas : “); scanf ( “%f”,&a);

Printf ( ” Masukkan Nilai tinggi : “); scanf ( “%f”,&t);

L = 0.5*a*t;

printf (” Luas Segitiga = % 6.2%f”,L);

getch();

}

/* Contoh Program Menggunakan Fungsi */

# include < stdio.h>

# include <conio.h >

main ()

{

hpslyr();

cw ( ” contoh Program Fungsi “, GREEN);

cw ( ” Press Any Key to Exit “, GREEN + BLINK);

getch();

}

hpslyr()

{

clrscr();

}

cw(teks,warna)

{

printf(“\n”);

textcolor(warna);

cprintf(text);

}

/* Menghitung Luas Lingkaran */

# include < stdio.h>

#include <conio.h>

main()

{

float luaslink,j ;

wlyr (BLUE)

cw (“Menghitung Luas Lingkaran “);

cw (“Masukkan nilai r : “,YELLOW );

scanf(” % f “,& j);

luaslink=luaslink(j);

cprintf ( ” Luas lingkaran = % .2f”,luaslink);

cw ( ” Press Any Key to Exit “, GREEN + BLINK);

getch();

}

wlyr(warna )

{

Textbackground(warna);

clrscr();

}

cw(teks,warna);

{

printf(“\n”);

textcolor(warna);

}luas link (r)

float r;

{

return (3.14*r*r);

}

  1. Belum ada komentar.
  1. No trackbacks yet.

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

%d blogger menyukai ini: