Hi There,

I'm a begginer in C++. In the program below the value must be returned to display the appropriate message. I expiriencing problems trying to compile the program. The erro message:

[Warning] In function `bool passOrNot(char)':
 non-lvalue in assignment

Can you help. Thanks

#include <iostream>
using namespace std;
int symbol(int m)
{

  {if (m > 0 && m < 40)
          m = 'F';
   else if (m > 39 && m < 50)
          m = 'E';
   else if (m > 49 && m < 60)
          m = 'D';
   else if (m > 59 && m < 70)
          m = 'C';
   else if (m > 69 && m < 80)
          m = 'B';
   else if (m > 79 && m < 100)
          m = 'A';  
 }   
  return m;
}

bool passOrNot(char symb)
 {
  if (symb = 'E' || symb = 'F')
    return false;
  else
    return true;  
 }  

int main( )
{
    int mark;
    char symb;
    cout << "Enter the mark out of 100: ";
    cin >> mark;
    symb = symbol(mark);
    cout << "The symbol corresponding to " << mark << " is " << symb;
    if (passOrNot(symb))
        cout << ". You pass - congratulations!" << endl;
    else
        cout << ". Unfortunately you fail." << endl;
    return 0;
}

as my signature says: = != == (= is not the same as ==)


in this line: if (symb = 'E' || symb = 'F') you meant: if (symb [b]==[/b] 'E' || symb [b]==[/b] 'F') The first statement says: if (assigning 'E' to 'symb' succeeds) return true
The second statement says if (symb is equal to 'E') return true

Next time you post, please put your code between [code] your code here [/code] tags

Thanks!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.