c-programing-
c-programing-
I have the code so i need you to check them 🙂 and put them in one program
part A is in a file.
part B is this :
#include <iostream>
#include <math.h>//header files
using namespace std;
//global vairables declare
int var_x_1, var_x_2, var_x_3, var_y_1, var_y_2, var_y_3, centreX, centreY;
double radius;
//function declaration
void get3points();
void calucateCenterPoints();
void calucateRadiusValue();
void outputInfo();
int main() //start main function
{
get3points(); // function calling
calucateCenterPoints();
calucateRadiusValue();
outputInfo();
return 0;
} //end of main function
void get3points()
{
cout<<“First co-ordinates :-“<<endl; // user input
cin>>var_x_1>>var_y_1;
cout<<“Second co-ordinates :-“<<endl; //user input
cin>>var_x_2>>var_y_2;
cout<<“Third co-ordinates :-“<<endl; // user input
cin>>var_x_3>>var_y_3;
}
void calucateCenterPoints()
{
//calculation for finding ‘x’ co-ordinates of center
centreX = -1 * ((( var_x_3*var_x_3 – var_x_2*var_x_2 + var_y_3*var_y_3 – var_y_2*var_y_2)/(2*(var_y_3-var_y_2)) ) -((var_x_2*var_x_2 – var_x_1*var_x_1 + var_y_2*var_y_2 – var_y_1*var_y_1)/(2 *(var_y_2-var_y_1)))) /((var_x_2-var_x_1)/(var_y_2-var_y_1))-((var_x_3-var_x_2)/(var_y_3-var_y_2));
//calculation for finding ‘y’ co-ordiunates of center
centreY = (-1 * centreX*((var_x_2-var_x_1)/(var_y_2-var_y_1))) +( (var_x_2*var_x_2 – var_x_1*var_x_1 + var_y_2*var_y_2 -var_y_1*var_y_1)/ (2 * (var_y_2-var_y_1)) );
}
void calucateRadiusValue()
{
//calculateion for radius of circle
radius = sqrt( pow(centreX-var_x_1, 2)+ pow(centreY-var_y_1, 2));
}
void outputInfo()
{
//print the info on the console
cout<<“Centre is “<<centreX<<” , “<<centreY<<endl;
cout<<“Radius is “<<radius<<endl;
}
