C++ Function Return Value
#include <iostream> #include <cstdlib> using namespace std; int myFunc1(int original) { int result = original * 2; result = result + 10;// w w w . j av a2s.co m result = result * 4; cout << "Calculating " << result << endl; return result * 10; } int myFunc2(int original) { int result = original + 10; result = result - 2; cout << "Calculating " << result << endl; return result; } int main() { int rabbits = 5; int antelopes = 5; rabbits = myFunc1(rabbits); cout << "Rabbits now at " << rabbits << endl; antelopes = myFunc2(antelopes); cout << "Antelopes now at " << antelopes << endl; return 0; }