Apr 22, 2014 at 11:24pm UTC
Hello all. I'm writing a simple function to calculate the co-volume parameter for a mixture, but I can't seem to remember how to reference one of seven variables which need to be changed within a for loop:
Formula is
http://i.imgur.com/KrAt5tK.png
I just hard declared my variables because I didn't feel like importing a file. My skills are very basic.
Basically I need to call on the p1,p2,p3...p7 and the b1,b2,b3...b7 in the loop.
It's been a while since I took this in school and I forget references/ pass-by references.
ignore the alphas, they're for another calculation...
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
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
double p1 = .6622;
double p2 = .1194;
double p3 = .100452;
double p4 = .45966;
double p5 = .05;
double p6 = .011041;
double p7 = .010941;
double alphaa1=7213.656;
double alphaa2=21837.76;
double alphaa3=41018.38;
double alphaa4=66442.81;
double alphaa5=98975.62;
double alphaa6=138886.7;
double alphaa7=185115.3;
double b1=.428865;
double b2=.648426;
double b3=.901549;
double b4=1.159367;
double b5=1.444116;
double b6=1.746952;
double b7=2.043129;
double amix=0;
double bmix=0;
double x;
double y;
for (int i = 1;i<8;i++){
y = //something along the lines of pi*bi
bmix = bmix + y;
}
Thanks in advance for any help and your time.
Last edited on Apr 22, 2014 at 11:25pm UTC