title: How to make a calculator in c++ using if else and functions?
body: <p>I am a new contributor and here I am trying to make a simple calculator but having errors in my code. When I compile the code I get:  </p>
  
  <pre><code>Error: C:\Users\IJLAL\Documents\collect2.exe    [Error] ld returned 1 exit status while compiling 
  </code></pre>
  
  <p>In case it could help, here is the screen shot of error when I pressed compile button or F11 in Dev C++:
  <a href="https://i.stack.imgur.com/STyAo.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/STyAo.png" alt="enter image description here"></a></p>
  
  <p>Here is my code: </p>
  
  <pre><code>#include&lt;iostream&gt;
  using namespace std;
  void fun(float a, float b); 
  int main()
  {   
      float a, b, sum, sub, mul, divide, mod;
      char op;
  
      //operands and operators are enterd by the user
      cout&lt;&lt;"Enter any two operands with operator=";
      cin&gt;&gt;a&gt;&gt;op&gt;&gt;b;
      fun(a, b);
      return 0;
  }
  void op(float a, float b)
  {
      if(a+b)
      {
          float sum=a+b;
          cout&lt;&lt;"\nAddition of two numbers is="&lt;&lt;sum;
      }
      else if(a-b)
      {
          float sub=a-b;
          cout&lt;&lt;"\nSubtraction of two numbers is="&lt;&lt;sub;
      }
      else if(a*b)
      {
          float mul=a*b;
          cout&lt;&lt;"\nMultiplication of two numbers is="&lt;&lt;mul;
      }
      else if(a/b)
      {
          float divide=a/b;
          cout&lt;&lt;"\nDivision of two number is="&lt;&lt;divide;
      }
      else
      {
          cout&lt;&lt;"\nInvalid operator.......";
      }
  }
  </code></pre>
  
  <p>Please tell me the solution of this problem, so that I can compile the code successfully. If there is any better solution to make a simple calculator on <strong>beginner level</strong> please mention it in answer. </p>