"Run-Time Check Failure #3" -- variables cannot be initialized

I am trying to write this program that finds the area and the perimeter of a specific figure. Everything seems to be working other than the fact that it keeps telling me, "Run-Time Check Failure #3 - The variable 'A_Trig' is being used without being initialized." This goes for all the variables that either start with A_" "or P_" " in lines 18 and 19(I made the text bold where it is telling me where the error is). Can someone please help me solve this problem? I have been attempting for the past few hours and still cannot get it. Thanks a lot!


#include<fstream>
#include<iomanip>
#include<iostream>
#include<math.h>
#include<stdlib.h>

using namespace std;

int main()
{
double a,b,c,d,e,f,g;
double pi=acos (-1.0);
double A_Trig,A_Rect,A_Ellipse,A_Circle,A_Par;
double P_Trig,P_Rect,P_Ellipse,P_Circle,P_Par;
double Area=A_Trig+A_Rect+A_Ellipse+A_Circle+A_Par;
double Perimeter=P_Trig+P_Rect+P_Ellipse+P_Circle+P_Par;

ofstream output ("C:result.dat");
cout<<"Tyler Perry"<<endl;
output<<"Tyler Perry"<<endl;
a=10.0;
b=3.0;
c=5.0;
d=4.0;
e=3.5;
f=11.0;
g=6.4;
A_Trig= 1.0/2*c*d;
A_Rect= f*a;
A_Ellipse=pi*b*c;
A_Circle=pi*pow(b,2),A_Par=e*a;
(A_Trig+A_Rect+A_Ellipse+A_Circle+A_Par);
cout<<"The area of the figure is="<<Area<<endl;
output<<"The area of the figure is="<<Area<<endl;
P_Trig=c+d+g;
P_Rect=(2*f)+(2*a);
P_Ellipse=(2*pi)*((pow(b,2))+(pow(c,2)),1.0/2)/2;
P_Circle=(2*pi)*(pow(b,2)),P_Par=2*(e+a);
(P_Trig+P_Rect+P_Ellipse+P_Circle+P_Par);
cout<<"The perimeter of the figure is="<<Perimeter<<endl;
output<<"The perimeter of the figure is="<<Perimeter<<endl;
system("PAUSE");
return 0;
}
Last edited on
It means that you are using A_Trig etc without having first given them a value. Perhaps you need to move the assignments to Area and Perimeter down below where you calculate the values for the A_ and P_ variables?
do you mind showing me what you mean? I am really new at this so it would be a lot easier if I could visually see what you mean. Thanks.
I GOT IT!!! THANK YOU SOOOOOOOOOOO MUCH! :D
Topic archived. No new replies allowed.