Mahmoud_Hawara

calculate the volume of the sphere

Oct 28th, 2024
402
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.39 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     cout << "Program to calculate the volume of a sphere\n";
  8.     cout << "-------------------------------------------\n";
  9.     cout << "Enter the radius of the sphere: ";
  10.     float r;
  11.     cin >> r;
  12.     float volume = 4.0 / 3.0 * M_PI * pow(r, 3);
  13.     cout << "The volume of the sphere is: " << volume;
  14.     return 0;
  15. }
Advertisement
Add Comment
Please, Sign In to add comment