only one input, multiple outputs and calls

I am having difficulty and have already seen most of the post on google about this.
I want to make a function that would receive 1 input and have 9 outputs, multiple times for different values of air temperature.
Inside this i write what needs to happen , but at the same time call other interpolation functions.
the output goes to main.

i have tried and had a little succes with struct, but it gives me unnexpected errors for all that exceeds 2 outputs.

i have 4 air temperatures,need to call the struct/function/etc each time, and at some point i will LAO have to call a similar one for a gas temperature, multiple times inside a single loop, each time a "cout" is necessary for each iteration of the while, but to get there i need to have the air values first...it's for a later time

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
73
74
75
76
77
78
79
80
81
82
 struct ProprietatiAer{ double densitateAN; double cAm, double iA, double densitateA, double etaA, double niuA, double lambdaA, double aA, double PrA };

ProprietatiAer propA(double tempa)
{
	double densitateAN{ 1.2928 };
//entalpia
	double cAm = InterpolareEntalpieAer(tempa);
	double iA = cAm*tempa;
//densitatea la o temperatura oarecare:
	double densitateA = densitateAN*(273.15 / (tempa + 273.15));
//vascozitate cinematica
	double etaA = InterpolareEtaAer(tempa);
	double niuA = etaA/ densitateA;
//difuzivtatea termica a aerului
	double lambdaA = InterpolareLambdaAer(tempa);
	double aA = (lambdaA / (densitateA*cAm))*densitateAN;
//Prandtl pentru aer
	double PrA = niuA / aA;
//return
	ProprietatiAer ret;
	ret.densitateAN;
	ret.cAm;
	ret.iA;
	ret.densitateA;
	ret.etaA;
	ret.niuA;
	ret.lambdaA;
	ret.aA;
	ret.PrA;

main()...

//1

	std::cout << "1) temperatura aerului la intrare: tAprim = " << tAprim << "\n\n";

	ProprietatiAer ret = propA(tAprim);
	double aerprim0 = ret.densitateAN;
	double aerprim1 = ret.cAm;
	double aerprim2 = ret.iA;
	double aerprim3 = ret.densitateA;
	double aerprim4 = ret.etaA;
	double aerprim5 = ret.niuA;
	double aerprim6 = ret.lambdaA;
	double aerprim7 = ret.aA;
	double aerprim8 = ret.PrA;

	std::cout << "entalpia:\n";
	std::cout<<"cAmprim = " << aerprim[1] << " kJ / m3N*grad\n";
	std::cout << "iAprim = " << aerprim[2] << " kJ/m3N\n\n";

	std::cout << "densitatea la o temperatura oarecare:\n";
	std::cout << "densitateAprim = " << aerprim[3] << " kg/m3\n\n";

	std::cout << "vascozitate cinematica:\n";
	std::cout << "etaAprim = " << aerprim[4] << " *10^-6 Pa*s\n";
	std::cout << "niuAprim = " << aerprim[5] << " *10^-6 m2/s\n\n";

	std::cout << "difuzivtatea termica a aerului:\n";
	std::cout << "lambdaAprim = " << aerprim[6] << " *10^-3 W/m*K\n";
	std::cout << "aAprim = " << aerprim[7] << " *10^-6 m2/s\n\n";

	std::cout << "Prandtl pentru aer:\n";
	std::cout << "PrAprim = " << aerprim[8] << "\n\n";
}

//functions for interpolation, only y changes for different ones
double InterpolareEntalpieAer(double tempea)
//please dissregard possible errors, it is still raw
{
	std::vector<double> tempaer = { 0, 100, 200, 300 };
	std::vector<double> y = { 1.297, 1.3, 1.307, 1.317 };
	int i{ -1 };
	double returni{ 0 };

	if (tempea > 0 && tempea < 100) i = 0;
	if (tempea > 100 && tempea < 200) i = 1;
	if (tempea > 200 && tempea < 300) i = 2;

	returni = ((tempea - tempaer[i]) / (tempaer[i + 1] - tempaer[i]))*(y[i + 1] - y[i]) + y[i];
	return returni;
}
Replace the local variables (lin 4 to 18) with the struct variable.
E.g. on line 4: ret.densitateAN = 1.2928; // double densitateAN{ 1.2928 };

Remove lines 38 to 46. You don't need this local variables. Use the struct members directly. aerprim[1] etc. doesn't work either way.

E.g. line 49:
std::cout<<"cAmprim = " << ret.densitateAN << " kJ / m3N*grad\n";
thank you. i managed to get it to work, and also i read more on structs and corrected what other mistakes i made .
Topic archived. No new replies allowed.