Why did we put the GuessSum and GuessProduct at the end of our function?

Why not right after the Guess A,B,C declaration? I don’t understand why it affects it. The GuessSum and GuessProduct are separate, so why does it matter for the location?

Because the values for GuessA/B/C are given with

std::cin >> GuessA;
std::cin >> GuessB;
std::cin >> GuessC;

If you were to do

int GuessA, GuessB, GuessC;
const int GuessSum = GuessA + GuessB + GuessC;
const int GuessSum = GuessA * GuessB * GuessC;
std::cin >> GuessA;
std::cin >> GuessB;
std::cin >> GuessC;

Then you would be reading GuessA, GuessB, GuessC before they were given a value.

1 Like

Thank you!

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms