# How to make a table

• 02-06-2010
Zerocool2214
How to make a table
I've been having trouble all day, and been slaving over this program.
Quick Intro: This program computes overall heat loss of a cylindrical tank, depending on multiple measurements. I need this program to display height on the left and radii on the top, and then display the heat loss in a form of a table. I hit a major wall as soon as i began. The *for* loop i'm using is not doing what i want it to do, and i know why, but not know how to fix it. I need it to start at user specified height/ radius and then increase by user specified increment to user specified values.

Example: I pick 30 feet, 10 values to be displayed, and 1 feet increments
my loop is just infinite, as it wont stop at a user specified value
here's my loop

Code:

``` {         for(height = height; height>=0; height+=x)     cout << height <<"  " << endl; }```
and here's the whole code

Code:

``` /* This program was made by Andrew Arellano on 1/25/2010 */ #include<iostream> #include<cmath> #include<windows.h> #include<iomanip> using namespace std; int main() {     system("color 02");         cout <<"Andrew Arellano\n";     cout <<"659806045\n\n";            cout <<"This program calculates the overall rate of heat loss from a \n";     cout <<"cylindrical tank, given the dimensions of the tank, the thermal \n";     cout <<"conductivity of the tank walls, and the internal and external temperatures.\n\n";         Sleep(5000);         //Declare all variables        double rate_heat (0.0), thermal (0.0), thick (0.0), hot (0.0), cold (0.0), rate_radial (0.0);     double height (0.0), radius_in (0.0), radius_wall (0.0), area (0.0), thick_feet (0.0), rate_total (0.0);     const double PI = 3.141593;     double n_value (0.0), x (0.0), x_rad (0.0), x_value (0.0);         cout <<"Please enter in the thickness, in inches, of the tank wall\n";     cin >> thick;     cout <<"\n";         cout <<"Please enter in the thermal conductivity, in BTU/hr ft deg F.\n";     cin >> thermal;     cout <<"\n";         cout <<"Please enter in the temperature, in degress Farenheit, inside the tank\n";     cin >> hot;     cout <<"\n";         cout <<"Please enter in the temperature, in degrees Farenheit, outside the tank\n";     cin >> cold;     cout <<"\n";         cout <<"Please enter in the range of height, in feet, of the tank; beginning with a minimum value\n";     cin >> height;     cout <<"\n";         cout <<"Please enter in the number of values of height to be recorded\n";     cin >> n_value;     cout <<"\n";         cout <<"Please enter in the increment value\n";     cin >> x;     cout <<"\n";         cout <<"Please enter in the range of inside radii, in feet, of the tank; beginning with the minimum value\n";     cin >> radius_in;     cout <<"\n";         cout <<"Please enter in the number of values of radius to be recorded\n";     cin >> x_value;     cout <<"\n";         cout <<"Please enter in the increment value\n";     cin >> x_rad;     cout <<"\n";     {         for(height = height; height>=0; height+=x)     cout << height <<"  " << endl; }                 //Perform necessary calculations (rate of heat loss through the top).     area = 2 * radius_in * PI * height; // area=2*pi*inside radius*height     rate_heat = ((thermal * area) / thick) * ( hot - cold); //rate of heat loss through the top = ((thermal conductivity * area) / wall thickness)*(hot temp - cold temp)         //Perform necessary calculations (rate of heat loss through the sides).     thick_feet = thick/12; //Wall thickness/12 in order to convert it to feet     radius_wall = (radius_in + thick_feet) / (radius_in); //Radius (wall thickness included) / inside radius     rate_radial = ((2 * PI * thermal * height) / (log(radius_wall))) * (hot - cold); // side heat loss = (2*pi*thermal*height / natural log radius+thick) * (hot-cold)         //Perform necessary calculations (total amount of heat loss).     rate_total = rate_heat + rate_radial; //total heat loss = top heat loss + side heat loss         // min, values, increments             //Print user inputs     cout <<"According to your inputs\n";     cout << height <<" feet high\n";     cout << radius_in <<" feet (radius)\n";     cout << thick <<" inches thick\n";     cout << thermal <<" BTU/hr ft deg. F\n";     cout << hot <<" degrees Farenheit\n";     cout << cold <<" degrees Farenheit\n\n";         Sleep(5600);         //Print results     cout <<"The heat loss through the top is " << rate_heat <<" BTUs\n";     cout <<"The heat loss through the sides of tank is " << rate_radial <<" BTUs\n";        cout <<"And, the total rate of heat loss is " << rate_total <<" BTUs\n\n";         system("pause");     return 0; }```
• 02-06-2010
Salem
> for(height = height; height>=0; height+=x)
Well let's assume you want to start at 0, and work your way up to height.

Code:

```for ( h = 0 ; h < height ; h += x ) {   cout << "Do work for height = " << h << endl; }```
• 02-07-2010
Zerocool2214
i think i've found what i've been looking for, for the past 36 hours. i think i can use multi-dimensional arrays to create the table i need. but i keep getting the error size of array 'rad' has non-integral type double

if anyone can help me please thx
• 02-07-2010
Zerocool2214
ok i got rid of the error but i dont know how to make the table, and also note: i want the table to be made according to user input
• 02-07-2010
Salem
We've no idea what you've done to the code.

> i want the table to be made according to user input
What does that mean?
• 02-07-2010
Zerocool2214
sorry bout that, i mean if the user wants 10 values of height to be recorded i want it to increment the inital height 10 times, but i'm on to something different now, i figured out im going to ask the user for a min. value and a max. value and increment until the min reaches the max