Equation outputs the same number no matter what inputs!

Ok so I am having to do this project for school and it is where we use function s to compute all these different numbers related to heat transfer in a house. In the code I ask for some user inputs and then I compute the values based on that. For the Nusselt number I get 0 no matter what I put in.

I am compiling in cygwin on a windows. When i just normally compile it works except the above error. But if I use this which is what my TA gave me to compile it "g++ -Wall -Werror -pedantic -std=c++11 -lm input.cpp" then I get this error: "heat.cpp: In function ‘int main()’:
heat.cpp:42:17: error: ‘ra’ may be used uninitialized in this function [-Werror=uninitialized]
cc1plus: all warnings being treated as errors"

Also, I am getting HUGE numbers for the rayleigh number, like *10^14 magnitude, is this correct?

My code looks like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include <iostream>
#include <math.h>
#include <cmath>
#include "func.h"
using namespace std;
float Rayleigh(float, float, float, float );
float Nusselt(float);
float HeatT(float, float, float);

int main()
{
	float itf;
	float ot;
	float H;
	float L;
	float itk;
	float B;
	float ra;
	float A;
	
	cout<<"Enter the temperature of the house(F): ";
	cin>>itf;
	
	cout<<"Enter the temperature of the environment(K): ";
	cin>>ot;
	
	cout<<"Enter the height of the house(ft): ";
	cin>>H;
	
	cout<<"Enter the length of the house(ft): ";
	cin>>L;
	
	itk = Fahr2Kel(itf);
	B = 1/ot;
	A = L*H;
	
	float z;
	z = Rayleigh(B, itk, ot, L);
	cout<<"The Rayleigh Number is: "<< z;
	
	float y;
	y = Nusselt(ra);
	cout<<"The Nusselt Number is: "<<y;
	
	float x;
	x = HeatT(A, itk, ot);
	cout<<"The heat transfer rate is: "<<x;
	
	return 0;
}


float Rayleigh(float B, float itk, float ot, float L)
{
    float ra;
	ra = (9.81* B *(itk-ot)*pow(L,3)*0.7)/(0.00000000023716);
	return ra;
}

float Nusselt(float ra)
{
	float Nu;
	Nu = 0.59*(pow(ra,0.25));
	return Nu;
}

float HeatT(float A, float itk, float ot)
{
	float Q;
	Q = A*(itk-ot);
	return Q;
}


And the func.h file looks like this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
float Cent2Fahr(float t)
{
	float f;
	f=(t*1.8)+32;
	return f;
}

float M2Ft(float m)
{
	float ft;
	ft=100*m/30.48;
	return ft;
}

float Acre2Hectare(float a)
{
	float ha;
	ha=a*0.404685642;
	return ha;
}

float Nm2Invcm(float nm)
{
	float cm;
	cm=1/(nm*.0000001);
	return cm;
}

float Fahr2Kel(float fh)
{
	float k;
	k=((fh-32)/1.8)+273;
	return k;
}

float Ft2M(float feet)
{
	float mt;
	mt=30.48*feet/100;
	return mt;
}


Sorry, for the bulky code. Thanks in advance!
gcc wrote:
main.cpp|42|warning: 'ra' may be used uninitialized in this function [-Wmaybe-uninitialized]|
You are using uninitilized varible, which means that it is essentually random. In school it happens to be in memory containing zeroes, so it calls Nusselt(0) and at home it containg some random number.

Tell me, what ra equals to and where do you set it to be equal that value.
I figured it out, I had Nusselt(ra) even though right above it I had z equal to the rayleigh function which outputs ra. Changed it to Nusselt(z) and now it works. I define ra in like 56 if you're still curious. Thanks for the help anyways!
Topic archived. No new replies allowed.