'area' not declared in this scope
Posted
by
user1641173
on Stack Overflow
See other posts from Stack Overflow
or by user1641173
Published on 2012-09-02T00:17:04Z
Indexed on
2012/09/02
3:38 UTC
Read the original article
Hit count: 109
c++
I've just started learning c++ and am trying to write a program for finding the area of a circle. I've written the program and whenever I try to compile it I get 2 error messages. The first is:
areaofcircle.cpp:9:14: error: expected unqualified-id before numeric constant
and the second is:
areaofcircle.cpp:18:5: error: 'area' was not declared in this scope
What should I do? I would post a picture, but I'm a new user, so I can't.
#include <iostream>
using namespace std;
#define pi 3.1415926535897932384626433832795
int main()
{
// Create three float variable values: r, pi, area
float r, pi, area;
cout << "This program computes the area of a circle." << endl;
// Prompt user to enter the radius of the circle, read input value into variable r
cout << "Enter the radius of the circle " << endl;
cin >> r;
// Square r and then multiply by pi area = r * r * pi;
cout << "The area is " << area << "." << endl;
}
© Stack Overflow or respective owner