Tugas5.2

Run Settings
LanguageC++
Language Version
Run Command
#include <iostream> #include <cmath> using namespace std; int main() { int alas, tinggi, mode, sisi_miring; float luas, keliling; puts("========================================================="); puts("\tProgram Menghitung Segitiga Siku-Siku"); puts("========================================================="); cout<<"Masukan Mode\t"<<endl<<"[1:Luas, 2:Keliling]\t: "; scanf("%d",&mode); cout<<endl; cout<<"Masukan Alas Segitiga\t: "; scanf("%d",&alas); cout<<"\nMasukan Tinggi Segitiga\t: \n"; scanf("%d",&tinggi); puts("========================================================="); cout<<"Nilai Alas Adalah\t: "<<alas<<endl; cout<<"Nilai Tinggi Adalah\t: "<<tinggi<<endl; if (mode == 1){ luas = alas * tinggi * 0.5; printf("Mode yang dipilih \t: Menghitung Luas\nLuas Segitiga Adalah \t: %.2f\n", luas); } else if(mode==2){ sisi_miring = sqrt(pow(alas, 2)+pow(tinggi,2)); keliling = sisi_miring + alas + tinggi; printf("Mode yang dipilih \t: Menghitung Keliling\nKeliling Segitiga \t: %.2f\n", keliling); } else { printf("Kode Salah" ); } puts("========================================================="); cout<<"Syifa Asih Nirwana"<<endl; cout<<"nirwanasyifa9@gmail.com"<<endl; return 0; }
Editor Settings
Theme
Key bindings
Full width
Lines