Skip to content

Instantly share code, notes, and snippets.

@kdmkdmkdm
Created April 24, 2012 22:11
Show Gist options
  • Select an option

  • Save kdmkdmkdm/2484246 to your computer and use it in GitHub Desktop.

Select an option

Save kdmkdmkdm/2484246 to your computer and use it in GitHub Desktop.
variableScopeC++
// 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