Study

Indahnya Berbagi [Source Code Menghitung Segitiga & Array 2×2]

Sedikit berbagi..jawaban tugas kuliah..bagi yang mau copas ya monggo..tapi mohon sertakan di reference yaa..

Menghitung Luas Segitiga

# include <stdio.h>

# include <stdlib.h>

main()

{

/* deklarasi variabel */

float alas,tinggi,luas;

/* proses pengumpulan nilai-nilai variabel */

printf(“Hitung Luas Segitiga nn”);

printf(“Alas Segitiga = “); scanf(“%f”,&alas);

printf(“Masukkan tinggi = “); scanf(“%f”,&tinggi);

/* proses penghitungan nilai variabel dari menampilkan hasilnya */

luas=(alas*tinggi)/2;

printf(“Luas Segitiga = %3.2f”,luas);

printf(“nn”);

system(“pause”);

return 0;

}

Membaca Array 2 x 2

# include <stdio.h>

# include <stdlib.h>

main()

{

/* deklarasi isi array 2 dimensi */

int A[2][2] = {{1,2},{3,4}};

int i,j;

/* pembacaan array 2 dimensi */

printf(“Data Array : n n”);

for(i=0; i<=1; i++)

{

for(j=0; j<=1; j++)

{

printf(“%i “, A[i][j]);

}

printf(“n”);

}

system(“pause”);

return 0;

}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s