1. floating point stack underflow

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 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: ";

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);
}```

2. Originally Posted by Curtux
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.
Sure we can help, but could you tell us which function you are attempting to calling when you get the error.

Originally Posted by Curtux
Any other errors are not my worry now just the stack underflow.
Well, they are my worry. I'm not sure the code you provided would compile without errors, at the very least there should be many warnings, i.e. functions that should return a value but don't, etc...

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>  // Should be using <iostream> if available
#include <conio.h>
using namespace std;   // Addresses issue of namespaces if you change header as suggested
#define PI 3.141592

// Function prototype
// None of the functions below actually appear to need to return any value judging
// by your implementation of them further below
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 */

// These really should be local variables, there is no great need for them to be global
char r;
char t;
char c;
char p;
float length;
float width;
float height;
float area;
char choice;
////////////////////////////////////////////////////////////////////////////

void main()  // int main always
{
// 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;

// The part in red below should be input == 'y' || input == 'Y'
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
}

////////////////////////////////////////////////////////////////////////////
// As mentioned above, you have no return statement
// indicating that the function returns a value although you do
// have a return type specified
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();
}

////////////////////////////////////////////////////////////////////////////
// As mentioned above, you have no return statement
// indicating that the function returns a value although you do
// have a return type specified
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();
}

// As mentioned above, you have no return statement
// indicating that the function returns a value although you do
// have a return type specified
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();
}

// As mentioned above, you have no return statement
// indicating that the function returns a value although you do
// have a return type specified
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
// At least you do have a return statement here although it
// serves no usefull purpose
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.
// At least you do have a return statement here although it
// serves no usefull purpose
float calc_triangle()
{
cout << "Enter the length of the triangle: ";
cin >> length;
cout << "Enter the height of the triangle: ";
cin >> height;

// This is an integer division operations and the result is 0
// Any time you call this function the output will ALWAYS be 0
// Replace the 1/2 with a simple 0.5f
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.
// At least you do have a return statement here although it
// serves no usefull purpose
float calc_circle()
{
cout << "Enter the radius of the circle: ";

cout << "\n";
cout << "The area of the circle is: " << area << "\n";

return(0);
}

// At least you do have a return statement here although it
// serves no usefull purpose
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);
}```

3. > while(input == 'y' || 'Y')
Try while(input == 'y' || input == 'Y')

When I compile, I get
prog.cpp(108) : error C4716: 'rectangle' : must return a value
prog.cpp(122) : error C4716: 'triangle' : must return a value
prog.cpp(134) : error C4716: 'circle' : must return a value
prog.cpp(146) : error C4716: 'para' : must return a value

> area = (1/2) * length * height;
1/2 is done in integer math (the result is always 0), so the entire result is also 0

No floating point underflow here - which compiler did you use (Turbo C ?)

The void main is wrong as well.

Also, you really should try using local variables, and passing parameters. A bunch of global variables and void functions is not good style.