When I run the program I get a floating point stack underflow error.
I have searched but I can't seem to seem to find the solution.
Any other errors are not my worry now just the stack underflow.
Code:/* This program will allow the user to display the formula for calculating the area of a figure. r = rectangle t = triangle c = circle p = parallelogram */ /////////////////////////////////////////////////////////////////////////// #include <iostream.h> #include <conio.h> #define PI 3.141592 // Function prototype float rectangle(); float triangle(); float circle(); float para(); float calc_rectangle(); float calc_triangle(); float calc_circle(); float calc_para(); /////////////////////////////////////////////////////////////////////////// // Variables //static float stack[1024]; /* 1024 should be MORE than enough */ char r; char t; char c; char p; float length; float width; float height; float radius; float area; char choice; //////////////////////////////////////////////////////////////////////////// void main() { // Variables char input; //////////////////////////////////////////////////////////////////////////// cout << "This program will allow the user to display the formula for\n"; cout << "calculating the area of a figure.\n"; cout << "\n"; cout << "Do you wish to continue? "; cin >> input; while(input == 'y' || 'Y') // Begin while loop { clrscr(); cout << "Please select the figure you wish to work with.\n"; cout << "\n"; cout << "r = rectangle\n"; cout << "t = triangle\n"; cout << "c = circle\n"; cout << "p = parallelogram\n"; cout << "\n"; cout << "Enter: "; cin >> choice; cout << "\n"; if (choice == 'r' || choice == 'R') { clrscr(); rectangle(); } else if (choice == 't' || choice == 'T') { clrscr(); triangle(); } else if (choice == 'c' || choice == 'C') { clrscr(); circle(); } else if (choice == 'p' || choice == 'P') { clrscr(); para(); } cout << "\n"; cout << "Do you wish to continue?"; cin >> input; }// End while loop } //////////////////////////////////////////////////////////////////////////// float rectangle() { cout << "The formula for calculating the area of a rectangle is length * width.\n"; cout << "\n"; cout << "Example: \n"; cout << "If the length of the rectangle is 6 and the width is 4 then:\n"; cout << "6 * 4 = 24\n"; cout << "The area of the rectangle is 24.\n\n"; area = calc_rectangle(); } //////////////////////////////////////////////////////////////////////////// float triangle() { cout << "The formula for calculating the area of a triangle is 1/2 * length * height.\n"; cout << "\n"; cout << "Example: \n"; cout << "If the length of the triangle is 6 and the height is 4 then:\n"; cout << "6 / 2 * 4 = 12\n"; cout << "The area of the triangle is 24.\n\n"; area = calc_triangle(); } float circle() { cout << "The formula for calculating the area of a circle is PI * radius * radius.\n"; cout << "\n"; cout << "Example: \n"; cout << "If the radius of the circle is 6 then:\n"; cout << "PI * 6 2\n"; cout << "The area of the circle is 24.\n"; area = calc_circle(); } float para() { cout << "The formula for calculating the area of a parallelogram is length * width.\n"; cout << "\n"; cout << "Example: \n"; cout << "If the length of the parallelogram is 6 and the width is 4 then:\n"; cout << "6 * 4 = 24\n"; cout << "The area of the parallelogram is 24.\n"; area = calc_para(); } //////////////////////////////////////////////////////////////////////////// // This function will calculate the area of a rectangle float calc_rectangle() { cout << "Enter the length of the rectangle: "; cin >> length; cout << "Enter the width of the rectangle: "; cin >> width; area = length * width; cout << "\n"; cout << "The area of the rectangle is: " << area << "\n"; return(0); } //////////////////////////////////////////////////////////////////////////// // This function will calculate the area of a triangle. float calc_triangle() { cout << "Enter the length of the triangle: "; cin >> length; cout << "Enter the height of the triangle: "; cin >> height; area = (1/2) * length * height; cout << "\n"; cout << "The area of the triangle is: " << area << "\n"; return(0); } //////////////////////////////////////////////////////////////////////////// // This function will calculate the area of a cicle. float calc_circle() { cout << "Enter the radius of the circle: "; cin >> radius; area = PI * radius * radius; cout << "\n"; cout << "The area of the circle is: " << area << "\n"; return(0); } float calc_para() { cout << "Enter the length of the parallelogram: "; cin >> length; cout << "Enter the width of the parallelogram: "; cin >> width; area = length * width; cout << "\n"; cout << "The area of the parallelogram is: " << area << "\n"; return(0); }