Howdy all,

I just started programming some 1 days ago, I have the program complete except for the following problem-- iteration. I consider myself pretty engineering savy when it comes to Excel and have created a spreadsheet to calculate this already, but I would like to create a simple program to do it as well.

Just as a reference my Excel formula (modified for my C++ names instead of cells)is:

For those unfamiliar, the equation deals with friction loss through a pipe and outputs a friction factor to then be used in a pressure drop calculation. All of the required values are already either inputted or calculated. The problem is the same factor on both sides of the equation (f), see below.Code:=IF(re>4000,(1/(-2*LOG(rrough/3.7 + 2.51/(rnum*SQRT(SAMECELL+1E-300))))^2),"0") This code uses iteration and circular references within Excel to get a value to 1-E6 accuracy or 1000 iterations.

The original equation is:

Since my experience in C++ is lacking I was looking for someone to "show me the way," I am not used to doing math the way C++ handles it. I currently have most of the pieces defined,Code:1/sqrt(f) = -2 * log10((e/3.7D) + ((2.51/Re*sqrt(f)))).but I know I do not have this setup correctly

I think I would limit the program to 500 iterations and/or 1-E6 accuracy. If I can provide anymore detail I will.Code://TURBULENT if (rnum > 4000) { t1 = 1 t2 = -2 t3 = log t4 = rrough t5 = 3.7 t6 = 2.51 t7 = rnum t8 = t9 = tpfc = cout<< "TURBULENT (RE > 4000)\n"; cout<<"\n"; cout<< "PIPE FRICTION COEFFICIENT (F=): \n"; cout<< tpfc << endl; }

Regards,

McJ