I wrote a practice program for my class, and everything in it works except for returning the value of a variable. My question is, why isn't it returning the value? Here is sample code I wrote out to avoid having to copy and paste large parts of code that aren't relevant.
#include <iostream> using std::cout; using std::cin; using std::endl; using std::fixed; #include <iomanip> using std::setw; using std::setprecision; int testing(); int main() { testing(); return 0; } int testing() { int debtArray[] = {4,5,6,7,9,}; int total = 0; for(int debt = 0; debt < 5; debt++) { total += debtArray[debt]; } return total; }
testing();tostd::cout << testing();and see if you don't get something.testingfunction does indeed return a value. But you simply discard that value in the call. What did you expect to happen?