- Luas Persegi : P * L
- Keliling Persegi : (2P) + (2L)
Langkah-langkahnya :
- Ketik perintah dibawah ini di TurboC++
#include<conio.h>
#include<iostream.h>
void main()
{ clrscr();
struct menghitung_persegi
{ char nama[25];
char kelas[5];
long int nim,pjg,lbr,lp,kl;
} persegi;
cout<<"======================================="<<endl;
cout<<" Program Menghitung Persegi "<<endl;
cout<<"======================================="<<endl;
cout<<"Nama : ";
gets(persegi.nama);
cout<<"Nim : ";
cin>>persegi.nim;
cout<<"Kelas : ";
cin>>persegi.kelas;
cout<<"======================================="<<endl;
cout<<"Panjang : ";
cin>>persegi.pjg;
cout<<"Lebar : ";
cin>>persegi.lbr;
persegi.lp=persegi.pjg * persegi.lbr;
persegi.kl=(2*persegi.pjg)+(2*persegi.lbr);
cout<<"========================================="<<endl;
cout<<"Luas Persegi : "<<persegi.lp<<endl;
cout<<"Keliling Persegi : "<<persegi.kl<<endl;
cout<<"========================================="<<endl;
getch();
}
- Jika sudah selesai , jalankan program tersebut atau bisa tekan tombol kombinasi CTRL + F9
Semoga bermanfaat buat anda .
0 Comment:
Post a Comment