Write a program to find the Volume of a sphere.
Volume of a sphere: (4/3) × pi × r^3;
pi: 3.14 ;
r: radius of sphere
Input:
Output:
Volume of a sphere: (4/3) × pi × r^3;
pi: 3.14 ;
r: radius of sphere
Input:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | #include <iostream.h> #include <conio.h> int main() { cout << "Volume of sphere Formula:(4/3) * pi * r^3 \n"; float a, r, r2, r3, V; cout << "Enter the value of Radius?\n"; cin >> r; r2 = r * r; r3 = r2 * r; a = (4/3) * 3.1415; V = a * r3; cout << "\t\"The Volume of sphere\" = " << V << " m^3 " << endl; getch(); return 0; } |
Output:
Volume of sphere Formula:(4/3) * pi * r^3 Enter the value of Radius? 4.5 "The Volume of sphere" = 286.269 m^3
No comments:
Post a Comment