Tugas 5.2

Run Settings
LanguageC++
Language Version
Run Command
#include <iostream> #include <cmath> using namespace std; int main() { puts("==========================================="); puts(" Program Menghitung Segitiga Siku-Siku"); puts("==========================================="); int alas, tinggi,mode, sisi_miring; float luas, keliling; cout<<"Masukan Mode"<<endl<<"[1:luas, 2:keliling]\t:"; scanf("%d", &mode); cout<<endl; cout<<"Masukan alas segitiga \t:"; scanf("%d", &alas); cout<<"\nMasukan tinggi segitiga :\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:%.2f \n", luas); }else if (mode == 2){ sisi_miring = sqrt(pow(alas, 2)+pow(tinggi,2)); keliling = sisi_miring + tinggi + alas; printf("Mode yang dipilih \t:Menghitung Keliling\nKeliling segitiga \t:%.2f\n", keliling); } puts("============================================"); cout<<"Sarah Ahmad Maula"<<endl; cout<<"sarahahmadmaula@gmail.com"<<endl; return 0; }
Editor Settings
Theme
Key bindings
Full width
Lines