satriafu5710

Luas & Volume Kerucut dengan Fungsi C++

Dec 5th, 2020 (edited)
384
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.84 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. float luasPermukaan(float r, float s)
  5. {
  6.     float phi = 3.14;
  7.     float hasil;
  8.  
  9.     hasil = phi * r * (r + s);
  10.     return hasil;
  11. }
  12.  
  13. float volumeKerucut(float r, float t)
  14. {
  15.     float phi = 3.14;
  16.     float hasil;
  17.  
  18.     hasil = 1 / (float)3 * phi * r * r * t;
  19.     return hasil;
  20. }
  21.  
  22. int main()
  23. {
  24.  
  25.     float phi = 3.14;
  26.     float r, tinggi, s; // s = Panjang Garis Pelukis
  27.     float luasP, volume;
  28.  
  29.     cout << "\t Luas Permukaan & Volume Kerucut \n\n";
  30.  
  31.     cout << " Masukkan Jari-jari  : ";
  32.     cin >> r;
  33.     cout << " Masukkan Tinggi : ";
  34.     cin >> tinggi;
  35.     cout << " Masukkan S      : ";
  36.     cin >> s;
  37.  
  38.     luasP = luasPermukaan(r, s);
  39.     cout << "\n Luas Permukaannya : " << luasP;
  40.  
  41.     volume = volumeKerucut(r, tinggi);
  42.     cout << "\n Volume Kerucutnya : " << volume;
  43. }
Add Comment
Please, Sign In to add comment