Answer» alright i have been LEARNING C++ from a book and i have gotten pretty alright with it but the person whowrote it must be well not very bright he didnt TELL you what to make the exetension i was trying to run this program but i didnt know the exetention i tryed .c but it didnt work so does anyone know what it is oo yea can u guys look at my script its doin math
#include #include #include /* Name: billy Author: billy Description: A General Formula Program made in C++ Date: 10/17/05 Copyright: i dont know */
//Universal variable for pi float pi = 3.14;
//Forumla used for Distance formula int f_Distance() { //Declare the variables float x_Sub1, x_Sub2, y_Sub1, y_Sub2, y_Answer, x_Answer, f_Answer;
//User inputs here cout << "\n\nPlease INSERT Ysub2: "; cin >> y_Sub2; cout << "Please insert Ysub1: "; cin >> y_Sub1; cout << "Please insert Xsub2: "; cin >> x_Sub2; cout << "Please insert Xsub1: "; cin >> x_Sub1;
//The actual calculations y_Answer = (y_Sub2 - y_Sub1) * (y_Sub2 - y_Sub1); x_Answer = (x_Sub2 - x_Sub1) * (x_Sub2 - x_Sub1); f_Answer = sqrt (y_Answer + x_Answer);
//The Final Answer cout << "\n\nThe distance is " << f_Answer; }
//Formula used for Midpoint int f_Midpoint () { //Declaring the variables float x_Sub1, x_Sub2, y_Sub1, y_Sub2, y_Answer, x_Answer;
//User inputs here cout << "\n\nPlease insert Xsub1: "; cin >> x_Sub1; cout << "Please insert Xsub2: "; cin >> x_Sub2; cout << "Please insert Ysub1: "; cin >> y_Sub1; cout << "Please insert Ysub2: "; cin >> y_Sub2;
// Formula Calculations x_Answer = ((x_Sub1 + x_Sub2)/2); y_Answer = ((y_Sub1 + y_Sub2)/2);
//Final answer output cout << "\n\nThe Mid-Point is (" << x_Answer << "," << y_Answer << ")"; }
//Formula for the circumference of a circle int f_Circumference () { //Declaring variables float f_Diam, f_Answer;
//User inputs here cout << "\n\nPlease insert the Diameter: "; cin >> f_Diam;
//Calculations f_Answer = (f_Diam * pi);
//Final answer Output cout << "\n\nThe Circumference is " << f_Answer; }
//Formula for area of a circle int f_Areacircle () { //Declaring variables float f_Radius; float f_Answer;
//User inputs here cout << "\n\nPlease insert the Radius: "; cin >> f_Radius;
//Calculations f_Answer = ((f_Radius * f_Radius) * pi);
//Final Answer output cout << "\n\nThe Area of the Circle is " << f_Answer; }
int main() { //Declaring the variable for the SWITCH statement int choice;
//The layouyt of the program cout << "-----Basic Geometry Formulas-----\n\n\n"; cout << "1. Distance Formula\n"; cout << "2. Mid-point Formula\n"; cout << "3. Circumference\n"; cout << "4. Area of a Circle\n\n"; cout << "Please select a choice: "; choice = getchar();
//Switch statement between the various formulas that the user picks switch(choice){ case '1': f_Distance(); break; case '2': f_Midpoint(); break; case '3': f_Circumference(); break; case '4': f_Areacircle(); break; default : return -1; } //Pause for one Key and close... cin.ignore(); cin.get(); return 0; }
k thanksIt really depends on the complier you're using. In general C programs have a extension of .C and C++ programs have .cpp
Hope this helps.
|