Created
April 24, 2012 22:11
-
-
Save kdmkdmkdm/2484246 to your computer and use it in GitHub Desktop.
variableScopeC++
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // variableScope.cpp : Defines the entry point for the console application. | |
| // | |
| #include "stdafx.h" | |
| #include <iostream> | |
| using namespace std; | |
| float gPI = 3.14f; | |
| float SphereVolume(float radius); | |
| int main() | |
| { | |
| cout << "PI = " << gPI << endl; | |
| cout << endl; | |
| float input0 = 0.0f; | |
| cout << "Enter a sphere radius: "; | |
| cin >> input0; | |
| float V = SphereVolume(input0); | |
| cout << "V = " << V << endl; | |
| } | |
| float ShpereVolume(float radius) | |
| { | |
| float V = (4.0f/3.0f)*gPI*radius*radius*radius; | |
| return V; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment