I am receiving an lldb error that I cannot get rid of with this code. The lldb debugger returns this information. I have changed things around, but the same error just shows up on another line. It always says thread breakpoint. Can anyone help?

ave1 double 7.7790454042181e-15
ave2 double 6.9532229757818e-310
first double 0
fourth double 0
second double 0
third double 0

 ``1234567891011121314151617181920212223242526272829303132333435`` `````` #include #include void deviation(double first, double second, double third, double fourth, double ave2); void average(double first, double second, double third, double fourth, double ave1); void average2(double first, double second, double third, double fourth, double ave1, double ave2); using namespace std; int main() { double first, second, third, fourth; double ave1, ave2; cout << "Enter four numbers." << endl; // lldb highlights this line of my code cin >> first >> second >> third >> fourth; average(first, second, third, fourth, ave1); average2(first, second, third, fourth, ave1, ave2); deviation(first, second, third, fourth, ave2); return 0; } void average(double first, double second, double third, double fourth, double ave1) { ave1 = (first + second + third + fourth) / 4; } void average2(double first, double second, double third, double fourth, double ave1, double ave2) { ave2 = (first - ave1) + (second - ave1) + (third - ave1) + (fourth - ave1); } void deviation(double first, double second, double third, double fourth, double ave2) { cout << sqrt(ave2); }``````
You're getting the breakpoint because ave1 and ave2 are uninitialized.

At line 22, your're passing ave1 by value. You calculate it, but it never gets returned, nor updated in the calling function.

Line 27, same problem with ave2.

You need to pass ave1 and ave2 by reference.
Last edited on
I have edited the code to include call by reference parameters, but I still get the same breakpoint error in the same location when I compile my code.

 ``1234567891011121314151617181920212223242526272829303132333435`` ``````#include #include void deviation(double first, double second, double third, double fourth, double ave2); void average(double first, double second, double third, double fourth, double& ave1); void average2(double first, double second, double third, double fourth, double& ave1, double& ave2); using namespace std; int main() { double first, second, third, fourth; double ave1, ave2; cout << "Enter four numbers." << endl; cin >> first >> second >> third >> fourth; average(first, second, third, fourth, ave1); average2(first, second, third, fourth, ave1, ave2); deviation(first, second, third, fourth, ave2); return 0; } void average(double first, double second, double third, double fourth, double& ave1) { ave1 = (first + second + third + fourth) / 4; } void average2(double first, double second, double third, double fourth, double& ave1, double& ave2) { ave2 = (first - ave1) + (second - ave1) + (third - ave1) + (fourth - ave1); } void deviation(double first, double second, double third, double fourth, double ave2) { cout << sqrt(ave2); }``````
Topic archived. No new replies allowed.