I'm getting the error no operator "=" matches these operands operand types are std::basic_ostream> = int when running code in C++ and i'm not sure whats actually causing the error.
#include <iostream>
#include <string>
#include <fstream>
#include <cctype>
using namespace std;
int main()
{
int num1, num2;
double average;
// Input 2 integers
cout << "Enter two integers separated by one or more spaces: ";
cin >> num1, num2;
//Find and display their average
cout << average = (num1 + num2) / 2;
cout << "\nThe average of these 2 numbers is " << average << "endl";
return 0;
}
cout << average = (num1 + num2) / 2;
probably doesn't do what you want. Check the operator precedence. – nwpcin >> num1, num2;
also doesn't do what you think it does – NathanOliveraverage = (num1 + num2) / 2; cout << average;
– Gillespiecout <<
doing there? You're displaying the average later. – molbdnilo"endl"
toendl
– Priyansh