Hey everyone,
I'm new on the forums and I'm also quite new still too C++ programming I'm taking a course in it in college (to meet my requirements) Its not my major and I'm terrible at math to boot. I have an assignment where the professor wants us to make a program that calculates the radius area and circumference of a circle based on 4 points the user enters, (the center and two points on the circle) I can get the program to start but when I go to enter numbers the program crashes with the following error:
Run-time error check failure #3- the varriable rad is being used without being initialized.
But I don't believe I need to initialize any of those, heres the code:
#include <iostream>
#include <iomanip>
using namespace std;
// prototypes go here
double radius(int,int,int,int);
double circumfrence(double, double);
double area(double, double);
int main()
{
int x1;
int x2;
int y1;
int y2;
double rad;
double circum;
double ar;
double radius1;
double circumfrence1;
const double pi=3.141616;
cout << "This Program Finds The Area, Radius and Circumfrence of a circle!" << endl;
cout << "Please where the center of the circle is, please enter two numbers " << endl;
cin >>x1;
cin >>y1;
cout << "Please enter a point of the circle, please enter two numbers " << endl;
cin >> x2;
cin >> y2;
radius1 = radius(x2,x1,y2,y1);
cout << "The Radius of the Circle is:" << rad << endl;
area(pi,radius1);
cout << "The Area of the Circle is:" << ar << endl;
circumfrence1 = circumfrence(pi,radius1);
cout << "The Circumfrence of the Circle is:" << circum << endl;
}
double radius(int p2,int p1, int c2, int c1)
{
double rad;
rad=(p2-p1)*(p2-p1)+(c2-c1)*(c2-c1);
return rad;
}
double area(double pi, double radius)
{
double ar;
ar=pi*(radius*radius);
return ar;
}
double circumfrence(double pi,double radius)
{
double circum;
circum=pi*(radius*2);
return circum;
}
I believe it has something to either do with my data types, return types or maybe just my equations. Although I am not to sure, any help on this would really be appreciated .