Tugas 5.1

Run Settings
LanguageC++
Language Version
Run Command
#include <iostream> using namespace std; //Nama : Dhafin Shabir Alfatih //Nim : 3420230036 int main() { int panjang; int lebar; int mode; cout<<"==========================================="<<endl; cout<<"\tProgram Percabangan Persegi"<<endl; cout<<"==========================================="<<endl; cout<<"Masukan Panjang Persegi :"<<endl; cin>>panjang; cout<<"Masukan Lebar Persegi :"<<endl; cin>>lebar; cout<<"==========================================="<<endl; cout<<"Masukan Mode"<<endl; cin>>mode; cout<<"[1:Luas, 2:Keliling]\t:"<<endl; cout<<"Panjang persegi adalah\t: "<<panjang<<endl; cout<<"Lebar Persegi adalah\t: "<<lebar<<endl; if (mode == 1) { cout<<"Mode yang dipilih adalah Luas"<<endl; int luas = panjang * lebar; cout<<"Luas Persegi adalah\t:"<<luas<<endl; } else if (mode == 2) { cout<<"Mode yang dipilih adalah keliling"<<endl; int keliling = 2 * (panjang + lebar); cout<<"Keliling Persegi adalah\t:"<<keliling<<endl; } else { cout << "Mode tidak valid"<<endl; } cout<<"==========================================="<<endl; cout<<"Nama\t: Dhafin Shabir Alfatih"<<endl; cout<<"Email\t: dhafinshabir610@gmail.com"<<endl; return 0; }
Editor Settings
Theme
Key bindings
Full width
Lines