Invalid operands of types 'int' and 'const char[2]' to binary 'operator<<' in main.cpp

The title explains the error I'm receiving for the code below. As I'm brand new to programming I'm hoping for, at the very least, a decent explanation of where I went wrong. Many thanks.

#include <iostream>
#include <cmath>
#include <iterator>
using namespace std;

int main ()
{
cout<<"Please enter an integer: ";
int n;
cin>>n;
if (n > 60)
{
cout << "We must shrink it by 25. The new number is: "<<n-=25<<"."<<endl; //ERROR: Invalid operands of types 'int' and 'const char[2]' to binary 'operator<<' in main.cpp
}
cout <<n<< " is a good number."<<endl;
return 0;
}
The -= precedence is probably not what you expect. Try putting that sub-expression in parentheses to ensure it is evaluated first.
Thanks for the info! (n=(n-25)) was needed.
Last edited on
Topic archived. No new replies allowed.