title: A simple addition,substraction,multiplication and division program
body: <p>A simple C++ calculator program to calculate addition, subtraction, multiplication and addition...</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  using namespace std;
  
  int main()
  {
      //input declarations as doubles for total and counter
      double total = 0, counter =0;
      //input declarations sign and Q as character
      char sign, Q = 0;
      //input declaration value as double
      double value;
  
  
  
          //A do..while will loop forever (or until we hit the break statement)
          do 
          {
              //The current value is 0.
              cout &lt;&lt; "Result :"&lt;&lt;" "&lt;&lt; total &lt;&lt; '\n';
  
              //Please enter an operation
              cout &lt;&lt; "Please enter an operation and number : ";
          cin &gt;&gt; sign;
  
          //If the operation is Q, the program will end.
          if (sign != 'Q')
  
          cin &gt;&gt; value;
              cin.ignore();
  
  
              // If the value input is &lt;=0, you can't divide anything by zero. 
              if (value &lt;= 0)
              {
                  cout &lt;&lt; "Unknown Operator " &lt;&lt; sign &lt;&lt;'\n' ;
              }
  
              //Otherwise procede with the calulator program
              else
              {
                  //If the operation is equal to '+', then the total is added.
                  if (sign == '+')
                  { 
                      total += value;
                  }
  
                  // If the operation is equal to '-', then the value is subtracted from the previous number input. 
                  else
                  {
                      if (sign == '-')
                      {
                          total -= value;
                      }
  
                      // If the operation is equal to '*', then the value is multiplied to the previous number input. 
                      else
                      {
                          if (sign == '*')
                          {
                              total *= value;
                          }
  
                          // If the operation is equal to '/', then the value is divided by the previous number input.
                          else 
                          {
                              if ((sign == '/')&amp;&amp;(value != 0))
                              {
                                  total /= value;
                              }
                          }
                      }
                  }
              }
          }
  
  
  
              //While the operation is not equal to 'Q', the program will run.
              while (sign != 'Q');
  
  
  
          return 0;
  }
  </code></pre>
  
  <p>The coding for the above program has no error but if i press "Q" to quit,it will display the last result non-stop. .Over and over and over and over again. . . Anyway,anyone know how to add square root to the program. . </p>