C++ Newbie needs simple help?

MissBlondie79

New member
Joined
Mar 31, 2011
Messages
0
Reaction score
0
Points
0
Our textbook is full of pseudocode, not actual code, and I'm having trouble getting the actual syntax for something right. I'm working on a very simple grade calculating program. If I wanted to say that if the grade is >= 85, set grade = "A". What is the proper syntax for this?
 
You can't use the same variable for a numerical grade and it's letter grade equivalent.

Use 2 variables, something like this:

double grade; // or you can use int if it's appropriate.

char gradeLtr;

if( grade >= 85 ) gradeLtr = 'A';

+add
Note the single quotes use with characters vs the double quotes used with strings.
 
Back
Top