The Basketball ball of the NBA has a standard dimension of 4.7 inch in radius, 9.4 inch in diameter, 29.5 inches in circumference, 22 ounces (size 7) in weight, and 7.5 - 8.5 pounds per square inch of air pressure.
Objective: Calculation of the Circumference, Area of a Circle and the Volume of a Sphere
Directive: #include <iostream>, #include <cmath>
Namespace: std
Function: main
Variables:
CircleRadius
double CircleCircumference
double CircleArea
double SphereVolume
Data types of variables: double
Statements: cout, cin, return
Input: Radius of the circle
Output:
Circumference of the Circle
Area of the Circle
Volume of the Sphere
C++ source code:
/*
PROGRAM : Circumference, Area of a Circle; Volume of a Sphere
AUTHOR: eternaltreasures
DATE: 2010 September 1
*/
#include <iostream>
#include <cmath>
using namespace std;
#define PI 3.14159
#define NEWLINE '\n'
int main ()
{
double CircleRadius;
double CircleCircumference;
double CircleArea;
double SphereVolume;
cout << "Enter the Radius of the Circle = ";
cin >> CircleRadius;
// Circumference of a Circle
CircleCircumference = 2 * PI * CircleRadius;
cout << "Circumference of the Circle = " << CircleCircumference;
cout << NEWLINE;
// Area of a Circle
CircleArea = PI * pow(CircleRadius, 2);
cout << "Area of the Circle = " << CircleArea;
cout << NEWLINE;
// Volume of a Sphere
SphereVolume = 4 * PI/3 * pow(CircleRadius, 3);
cout << "Volume of the Sphere = " << SphereVolume;
cout << NEWLINE;
return 0;
}
No comments:
Post a Comment