0

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;
}

Edited by mike_2000_17: Fixed formatting

2
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by Xokzin
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

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.