0
    if(per>=80)
  grade='A+';
    else if(per>=75&&per<=79)
  grade='A';
    else if(per>=70&&per<=74)
  grade='A-';
    else if(per>=65&&per<=69)
  grade='B+';
    else if(per>=60&&per<=64)
  grade='B';
    else if(per>=55&&per<=59)
  grade='B-';
    else if(per>=50&&per<=54)
  grade='C+';
    else if(per>=45&&per<=49)
  grade='C-';
    else if(per>=40&&per<=44)
  grade='D';
    else
            grade='F';

when i run this code i receive the message multicharacter character constant.I see previous solutions of the same problem but failed to implement it in my code.Please any one help me and tell me what should i use to run the code

Hatted Rooster
  • 35,759
  • 6
  • 62
  • 122
  • 1
    Hi. It's easier to answer your question if you provide a fully self-contained example, i.e., something that compiles (or triggers the warning / error that you see). Also, it is probably a good idea to say which compiler you are using with which options. – Lukas Barth Jul 20 '18 at 13:01

2 Answers2

2

It's your quotation marks. Single quotation marks around one character are used for char literals, single quotation marks around multiple characters are interpreted as a literal of integer type (See here), whereas double quotation marks around zero or more characters is interpreted as const char* (i.e. a c-string).

Therefore, your 'A+' is an int, not a char or string as you may have intended. The fix would be to use double quotes instead, assuming that grade is of type char* or std::string.

Ben Jones
  • 652
  • 6
  • 21
0

Apostrophe (') mark is used only for Characters, like single letter A. If you want to use A+ it's not single letter anymore, it's string. And for strings you should use Quotation Mark ("). So you need to change type of your grade variable to string instead of char and replace ' with ".

Cysio
  • 53
  • 6