Note that there are some explanatory texts on larger screens.

plurals
  1. POLLDB Error with Exponents on C++
    text
    copied!<p>I have updated my calculator code, and am adding an exponent function. However, when I try to get the answer to the equation, i get this error: (lldb) Any help would be greatly appreciated, as This is my first day with C++! Yep, that's all! Here's my code!</p> <pre><code>#include &lt;math.h&gt; #include &lt;iostream&gt; int int1, int2, answer; bool bValue(true); std::string oper; std::string cont; using namespace std; std::string typeOfMath; int a; int b; int answerExponent; int main(int argc, const char * argv[]){ // Taking user input, the first number of the calculator, the operator, and second number. Addition, Substraction, Multiplication, Division cout&lt;&lt;"______________________________________________\n"; cout&lt;&lt;"|Welcome to The ExpCalc! Do you want to do |\n"; cout&lt;&lt;"|Exponent Math, or Basic Math(+, -, X, %) |\n"; cout&lt;&lt;"|Type in 'B' for basic Math, and'E' for |\n"; cout&lt;&lt;"|Exponential Math! Enjoy! (C) John L. Carveth|\n"; cout&lt;&lt;"|____________________________________________|\n"; cin&gt;&gt; typeOfMath; if(typeOfMath == "Basic" || typeOfMath == "basic" || typeOfMath == "b" || typeOfMath =="B") { cout &lt;&lt; "Hello! Please Type in your first integer!\n"; cin&gt;&gt; int1; cout&lt;&lt;"Great! Now Enter your Operation: ex. *, /, +, -...\n"; cin&gt;&gt; oper; cout&lt;&lt;"Now all we need is the last int!\n"; cin&gt;&gt; int2; if (oper == "+") { answer = int1 + int2; } if (oper == "-") { answer = int1 - int2; }if (oper == "*") { answer = int1 * int2; }if (oper == "/") { answer = int1 / int2; } cout&lt;&lt;answer &lt;&lt; "\n"; cout&lt;&lt;"Thanks for Using The ExpCalc!\n"; }else if(typeOfMath == "Exp" ||typeOfMath == "E" ||typeOfMath == "e" ||typeOfMath == "Exponent"){ cout&lt;&lt;"Enter the desired Base. Example: 2^3, where 2 is the base.\n"; cin&gt;&gt; a; cout&lt;&lt;"Now what is the desired exponent/power of the base? Ex. 2^3 where 3 is the exponent!\n"; cin&gt;&gt;b; answerExponent = (pow(a,b)); cout&lt;&lt; answerExponent; } else(cout&lt;&lt;"Wrong String!"); } </code></pre> <p>Please help! I will probably ask a lot of questions aswell, so please dont get mad! I am also on a Mac, using Xcode 4!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload