Advertisement
Guest User

Untitled

a guest
Nov 21st, 2019
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.19 KB | None | 0 0
  1. // Program untuk menghitung nilai absolut dari 2 variabel
  2.  
  3. /*  Programmer  : William Handi Wijaya      Tanggal diselesaikan : 21 November 2019
  4.     NRP         : 05111940000087            Kelas                : Dasar Pemograman C */           
  5.        
  6.  
  7. #include <stdio.h>
  8. #define M_PI 3.14159
  9.  
  10. double getDouble(void);
  11.  
  12. int main(void)
  13. {
  14.    
  15.     printf("-------------Surface Area of a Cone-------------\n\n\n\n");
  16.     //Deklarasikan variabel - variabel yang digunakan
  17.     double  radius,             //panjang jari - jari alas kerucut
  18.             slant_height,       //tinggi sisi miring kerucut
  19.             surface_area;       //luas permukaan dari benda
  20.            
  21.     //Masukkan data panjang radius alas kerucut
  22.     printf("Please enter the circular base radius of the cone in cm => ");
  23.     radius = getDouble();
  24.    
  25.     //Masukkan data tinggi sisi miring pada kerucut
  26.     printf("Now, enter the slant height of the cone in cm => ");
  27.     slant_height = getDouble();
  28.    
  29.     //Masukkan data ke dalam formula perhitungan luas permukaan kerucut
  30.     surface_area = M_PI * radius * (radius + slant_height);
  31.    
  32.     //Tampilkan hasilnya pada layar monitor
  33.     printf("The surface area of the cone is %f square centimeters\n\n", surface_area);
  34.  
  35.     return 0;
  36. }
  37.  
  38. double getDouble(void)
  39. {
  40.     double a;
  41.     scanf("%lf", a);
  42.     return a;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement