Tugas Algoritma 5.2

Run Settings
LanguageC++
Language Version
Run Command
#include <iostream> #include <cmath> #include <cstdio> using namespace std; int main() { int mode; float alas, tinggi, sisi, keliling, luas; cout << "==============================================" << endl; cout << " Program Menghitung Segitiga Sama Kaki " << endl; cout << "==============================================" << endl; cout << "Masukkan Mode\n [1:Luas, 2:Keliling]\n "; cin >> mode; cout << "Masukkan Alas Segitiga :\n "; cin >> alas; cout << "Masukkan Tinggi Segitiga:\n "; cin >> tinggi; cout << "==============================================" << endl; if (mode == 1) { luas = (alas * tinggi) / 2; cout << "Nilai Alas Adalah : " << alas << endl; cout << "Nilai Tinggi Adalah : " << tinggi << endl; cout << "Mode yang dipilih : Menghitung Luas" << endl; cout << "Luas Segitiga : "; printf("%.2f\n", luas); } else if (mode == 2) { keliling = alas * tinggi; cout << "Nilai Alas Adalah : " << alas << endl; cout << "Nilai Tinggi Adalah : " << tinggi << endl; cout << "Mode yang dipilih : Menghitung Keliling" << endl; cout << "Keliling Segitiga : "; printf("%.2f\n", keliling); } else { puts("Mode tidak valid!"); } cout << "==============================================" << endl; puts("Nama \t\t: La ode ian"); puts("Nim \t\t: 3420210002"); return 0; }
Editor Settings
Theme
Key bindings
Full width
Lines