LLDB Error

I have encountered another problem that I cannot explain in my code. I use Xcode, and I am given an unusual message in the output box that says lldb. I am still new to programming and do not understand the meaning of these things. However, I think that this is another compilation error. Can anyone tell me why it is that this program will not compile?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
  #include <iostream>
#include <cmath>
double deviation(double first, double second, double third, double fourth);
double average(double first, double second, double third, double fourth);
double average2(double first, double second, double third, double fourth);
using namespace std;
int main()
{
    double first = 1.0, second = 2.0, third = 3.0, fourth = 4.0;
    return 0;
}

double deviation(double first, double second, double third, double fourth)
{
    return sqrt(average2(first, second, third, fourth));
}

double average(double first, double second, double third, double fourth)
{
    return (first + second + third + fourth) / 4;
}

double average2(double first, double second, double third, double fourth)
{
    return (first -  average(first, second, third, fourth)) + (second -  average(first, second, third, fourth)) + (third -  average(first, second, third, fourth)) + (fourth -  average(first, second, third, fourth));
}
LLDB is a debugger. Could you give us this unusual message so we can look at it?

Secondly, this code would do almost nothing. It would run the main function, which would set a local variable named first to 1, then second to 2, then third to 3, then fourth to 4. What I think you mean to do is call deviation(first, second, third, fourth); after you declare and initialize your four variables. After that, you would want to output it's return to console, so you would do something like the following:

(this is in your main function
1
2
3
4
double first = 1.0, second = 2.0, third = 3.0, fourth = 4.0;
double output = deviation(first, second, third, fourth);
cout << output << endl;
system("pause"); // runs the cmd command "pause" which waits for key input before closing so that you can see your program run 


The one-line method of doing that would be:
cout << deviation(1.0f, 2.0f, 3.0f, 4.0f) << endl;
Last edited on
Topic archived. No new replies allowed.