
Circle Area
Has any one got any idea why this doesn;t work!!
Code:
//Program to find circle values.
#include <iostream>
using namespace std;
int main()
{
float radius;
float pi;
pi = 3.14;
float r2;
r2 = radius*radius;
float area;
area = pi*r2;
{
cout << "Please input a radius so that I can work out the area of the circle!\n";
cin >> radius;
cout << "Thankyou! Your answer is below:\n";
cout << "you entered:" << radius;
cout << "/ncurrent status: not working";
//the above line is a debugging tool
}
return 0;
}

radius is unintialised at first use.
your structure needs work. how can you work out radius before asking for input etc.

In C/C++ (okay, probably every language) the equation you supply will be applied only when you physically do so. Doing math on variables before they are inputed is sort of like photographing a baby before it is born (without a better analogy :) ). try this:
Code:
int main(){
float radius;
float pi = 3.14;
float area;
cout << "Please input a radius so that I can work out the area of the circle!\n";
cin >> radius;
cout << "Thankyou! Your answer is below:\n";
cout << "you entered:" << radius;
area = (pi*radius*radius);
cout << "Area is : " << area;
return 0;
}

Yeah my structure needs work, I fixxed it now.