Hey guys, Just wondering if anyone could help me here..

I'm looking to perform a calculation over a range (say v= 0 - 100) and for C++ to display what the highest value of the equation is and for what value of v this occurs at.

e.g.

for (v=0; v<=100; v++) {

p = exp((v+0.5)*h*nu)/q; }Thanks :)

inside your loop you can add an if statement. if(p > max_value) { max_value = p; index_at = v; }

Thanks - so is that an if () break clause? Sorry, I'm a bit of a newbie at this :)

Unless you're sure the max would occur prior to the last iteration of v, you might as well let the loop terminate on its own. Try graphing the equation to see what it does.

Ask Your Question

Weekly Poll

Do you think manufacturers should do more to reduce phone and tablet usage among kids?

Discuss in The Lounge

Poll History