How do use the pow function with variables? i.e.

//equations for problem 9 page 99 part b
cT=(hT)/2;
iT=(base*(hT*hT*hT))/12;
LT=(sT*iT)/(8*cT);

*math.h file in program

how would i raise "hT" to the 3 power in correct c++ syntax?

Recommended Answers

All 2 Replies

use the pow function.

foo = pow(bar, 3);
commented: humorous and helpful +1

See http://cplusplus.com/reference/clibrary/cmath/pow/ for a reference. Watch out for the overloads that are allowed (i.e., there is no overload for an integer to the power of integer, so you'll need to do appropriate casting).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.