hallo....
kawan - kawan blogger semua ...dan juga para pecinta dunia IT. Postingan saya sebelumnya membahas tentang Apa Itu Bahasa Pemograman C++???, bagi teman - teman sekalian jika hanya membaca dan tidak mempraktekannya maka rasanya kurang malahan kita jadi tidak paham dengan apa yang dipelajari.
jadi, aku sedikiti berbagi nih, contoh Program C++ :
#include "iostream.h" #include "conio.h" void main () { clrscr (); cout << " Bangun Datar "<< endl ; cout << "=================== " << endl << endl ; const float PHI = 3.14 ; const float S = 0.5 ; int s, t, l, p, d1, d2, r, a ; int luas_1, kllg_1, luas_2, kllg_2; float luas_3, kllg_3, luas_4, kllg_4, luas_5, kllg_5 ; s = 4 ; // s adalah sisi t = 6 ; // t adalah tinggi l = 2 ; // l adalah lebar p = 3 ; // p adalah pangjang d1 = 12 ; // d1 adalah diagonal pertama d2 = 6 ; // d2 adalah diagonal kedua r = 7 ; // r adalah jari - jari a = 4 ; // a adalah alas luas_1 = s * s ; // luas persegi kllg_1 = 4 * s ; // keliling persegi luas_2 = p * l ; // luas persegi panjang kllg_2 = 2 * (p + l) ; // keliling persegi panjang luas_3 = S * a * t ; // Luas Segitiga kllg_3 = s + s + s ; // Keliling segitiga luas_4 = S * d1 * d2 ; // Luas layang-layang kllg_4 = s + s + s + s ; // Keliling layang - layang luas_5 = PHI * r * r ; // Luas Lingkaran kllg_5 = 2 * PHI * r ; // Keliling Lingkaran cout << " |Persegi| " << endl ; cout << " --------- " << endl ; cout << "|Sisi = " << "4" << " |" << endl ; cout << "|Luas = " << luas_1 << " |" << endl ; cout << "|Keliling = " << kllg_1 << " |" << endl ; cout << "-===========================- " << endl << endl ; cout << " |Persegi Panjang| " << endl ; cout << " ----------------- " << endl ; cout << "|Panjang = " << "3" << " |"<< endl ; cout << "|Lebar = " << "2" << " |"<< endl ; cout << "|Luas = " << luas_2 << " |"<< endl ; cout << "|Keliling = " << kllg_2 << " |"<< endl ; cout << "-===========================- " << endl << endl ; cout << " |Segitiga| " << endl ; cout << " ---------- " << endl ; cout << "|Alas = " << "4" << " |"<< endl ; cout << "|Tinggi = " << "6" << " |"<< endl ; cout << "|Luas = " << luas_3 << " |"<< endl ; cout << "|Keliling = " << kllg_3 << " |"<< endl ; cout << "-===========================- " << endl << endl ; cout << " |Layang - layang| " << endl ; cout << " ----------------- " << endl ; cout << "|Diagonal 1 = " << "12" << " |"<< endl ; cout << "|Diagonal 2 = " << "6" << " |"<< endl ; cout << "|Sisi = " << "4" << " |"<< endl ; cout << "|Luas = " << luas_4 << " |"<< endl ; cout << "|Keliling = " << kllg_4 << " |"<< endl ; cout << "-===========================- " << endl << endl ; cout << " |Lingkaran| " << endl ; cout << " ----------- " << endl ; cout << "|Jari - Jari = " << "7" << " |" << endl ; cout << "|Luas = " << luas_5 << " |" << endl ; cout << "|Keliling = " << kllg_5 << " |" << endl ; cout << "-===========================- " << endl << endl ; }
0 komentar:
Posting Komentar