C++ using if statement

Hello everyone. I have been asked to write a programme that outputs the calculations based on the values and operand used it is working however it does not display the difference correctly, is there something I didn't do correctly?

/Calculator
#include <iostream>
using namespace std;

int main( )

{
float var1, var2, sum, quotient, product, difference;
char operand;

cout << "Enter the 1st variable. ";
cin >> var1;
cout << "Enter the 2nd variable. ";
cin >> var2;
cout << "Enter the operation. ";
cin >> operand;

if ( sum = var1 + var2)
cout << sum << " is the sum of two variables." << endl;
else
cout << difference << product << quotient;

difference = var1 - var2;
product = var1 * var2;
quotient = var1 / var2;

cout << difference << " is the difference between variables." << endl;
cout << product << " is the product of variables." << endl;
cout << quotient << " is the quotient between variables." << endl;

return 0;
}
= is for assignment. Use == for comparison.
Topic archived. No new replies allowed.