A variable must be defined before you can use it.
When you define a variable the type is specified and an appropriate amount of memory reserved.
A simple definition has the following syntax:
type name1[, name2,...];
EXAMPLES:
char c; int i, counter; double x, y, size;
Variables can be defined either within the program's functions or outside of them.
The following code calculates circumference and area of a circle with radius 2.5
#include <iostream> using namespace std; const double pi = 3.141593; int main() /*from www.j a v a2 s .com*/ { double area, circuit, radius = 1.5; area = pi * radius * radius; circuit = 2 * pi * radius; cout << "\nTo Evaluate a Circle\n" << endl; cout << "Radius: " << radius << endl << "Circumference: " << circuit << endl << "Area: " << area << endl; return 0; }