Ask your own question, for FREE!
Computer Science 22 Online
OpenStudy (anonymous):

I have an Excel formula which I'm trying to write as a loop in C++. The formula starts off with the first cell being 0, then the next cell being: =MAX((N2-O2-P2)/B21,0). Any ideas?

OpenStudy (anonymous):

Assuming N2, 02, P2 and B21 are values you know to retrieve yourself in C++ somehow (without more info in what they're supposed to be can't say much there) then something like: #include <iostream> #include <algorithm> using namespace std; int main() { //for however many cells you want to run for for(int i = 0; i < numberOfCellsYouWantToRunFor; i++) { //assuming ints int N2 = getFunctionForN2(); int O2 = getFunctionForO2(); int P2 = getFunctionForP2(); int B21 = getFunctionForB21(); cout << max(((float) N2-O2-P2)/(float) B21), 0) << endl; } return 0; } Hope that helps. My C++ syntax might be a little rusty.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!