Advertisement
Guest User

calculate volume of cone (c++)

a guest
Apr 28th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.55 KB | None | 0 0
  1. // Calculate volume of a cone
  2. #include <iostream>
  3. #include <string>
  4. #include <math.h>
  5.  
  6. float radius = 1.5;
  7. float height = 10;
  8.  
  9. int main()
  10. {
  11.   float radius_S = pow(radius, 2);
  12.   std::string radius_S_string = std::to_string(radius_S);
  13.   std::cout << ("Radius^2: " + radius_S_string);
  14.   float radius_StH = radius_S * height;
  15.   std::cout << ("\nRadius^2*height: " + std::to_string(radius_StH));
  16.   float radius_StHtP = radius_StH * M_PI;
  17.   float radius_StHtPdOT = radius_StHtP * 1/3;
  18.   std::cout << ("\nVolume: " + std::to_string(radius_StHtPdOT));
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement