### C++ area calculator problem! [OS X 10.8.3] [Code::Blocks]

Hi there! I have been working on a C++ calculator for a few months now. It has taken a few months because I haven't has much time to work on it. So it has had about 2 weeks of work put into it. I am very happy with it. I made a thread not too long ago asking about how I would make a perimeter calculator. I got help on it and I thought 'Happy days! Now I can finally finish my calculator.' But the next day I thought 'If I can make a perimeter calculator, surely I can make an area calculator using a similar method, right?'

 ``123456789101112131415`` `````` cout << "You chose the perimiter calculator!" << endl; cout << "Please enter the amount of sides on your shape: " << endl; cin >> numberOfSides; long double sides[numberOfSides]; for(int x = 0; x < numberOfSides; x++) { cout << "Enter the length of one of your walls your shape: " << endl; cin >> sides[x]; sum += sides[x]; } cout << "The perimiter of the shape that you entered is: " << sum << endl;``````

So I thought since for the perimeter calculator I could do the same thing, but this time do `sum *= sides[x]` instead of `sum += sides[x]`, but as you can guess I had no luck.

I have been having 2 problems with this calculator. Here are the problems I have been having:

As you should be able to tell by the header just up there, the calculator always gives the answer 0 for the area calculator! It is only for the area calculator that this happens. Why does it always give 0? Is it because I am using the `*=` operator? I am really at a loss as to what to do here. I had my friend look at it and he cant figure out what's wrong with it either. Please help me with this!

2. SEGMENTATION FAULT: 11

After running any operation in the calculator, it should prompt the user if they want to use the calculator again. Before the area calculator, this worked. Once I added the area calculator, it comes up at the bottom of Terminal 'Segmentation Fault: 11'. I do not get this problem on Windows, but I still get the problem of the answer always being 0(see problem 1). I have not tried on Linux. I have Windows on my MacBook Pro and Ubuntu installed with WUBI. If someone could be of assistance to this issue please let me know =)

Thanks for reading this thread. If you can help I would be REALLY appreciative of it. Thanks in advance!!!

- CppCoder101
Topic archived. No new replies allowed.