Equation loads as a Pointer (Function)

Hi! I'm trying to load this program I wrote which includes switch-case menu, a function and an if else statement. When I run the program, it loads the menu perfectly but when its after allowing the user to input a letter, instead of allowing more inputs as desribed in the function, it jumps over to a pointer address. I used * in the equation since it's for multiplying but I'm not sure why it's loading strange. If someone could point me why its loading strange and how I could correct it, I would definitely appreciate it! Thank you!

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

#include <iostream>
#include <math.h>
using namespace std;
int fluidflow(int a, int b, int c);
int main()
{
	char letter;
	cout << "Please select a fluid" << endl;
	cout << "\n g. Gasoline";
	cout << "\n f. Fuel Oil";
	cout << "\n l. Lubricating Oil";
	cout << "\n s. Linseed Oil";
	cout << "\n w. water" << endl;
	cin >> letter;
	switch (letter)
	{
	case 'g': cout << "Gasoline" << endl;
		cout << fluidflow << endl;
		break;
	case 'f': cout << "Fuel Oil" << endl;
		cout << fluidflow << endl;
		break;
	case 'l': cout << "Lubricating Oil" << endl;
		cout << fluidflow << endl;
		break;
	case 's': cout << "Linseed Oil" << endl;
		cout << fluidflow << endl;
		break;
	case 'w': cout << "Water" << endl;
		cout << fluidflow << endl;
		break;
	default: cout << "Error" << endl;
	}

	system("pause");
	return 0;
}
int fluidflow(int a, int b, int c)
{
	int pd, vf, kv, rey;
	cout << "Enter Pipe Diameter (m), Fluid Velocity (m/s) & Kinematic Viscocity (m2/s at 40 Celcius):" << endl;
	cin >> pd >> vf >> kv;
	rey = ((pd * vf) / kv);
	if (rey < 2000)
		cout << "The fluid flow is laminar." <<"\n" << "Amount:"<< rey << endl;
	else if (2000 <= rey >= 3000)
		cout << "The fluid flow is transition." << "\n" << "Amount:" << rey << endl;
	else if (rey>3000)
		cout << "The fluid flow is turbulent." << "\n" << "Amount:" << rey << endl;
	else
		cout << "error" << endl;
	return rey;
}
cout << fluidflow << endl;

If you mean to print out the result of fluidflow, you need to include parenthesis and call it with the three int parameters it expects.

cout << fluidflow(a,b,c) << endl;

Though - I don't see what in the current main function you would be sending besides the type of liquid they've selected from the menu.


Edit:
Mathematical inequalities don't work like this in C++.
else if (2000 <= rey >= 3000)
Last edited on
Topic archived. No new replies allowed.