# Thread: how can i express

1. ## how can i express

Hello Everone.
I hope somebody can 'pointer' me in the correct direction ...my problem is in char/ascii conversions
i want to outpuit a Letter grade for an average that i have caluculated in the previous fx- but i am unsure if i need to call
an "A" 65?. I will be returning this "grade" to a previous function that calls all of my calculations, and THEN drops them into their place in my struct. Hope that's enuf info...
I am getting 2 types of errors on the following Fx syntax
1.
'<=' : unsafe use of type 'bool' in operation
2.
'A' : undeclared identifier

Can someone perhaps tell me what is off about my expression?

This is one teeny piece of a huge puzzle i am working on and i 'm finding myself kinda stuck and help is much appreciated...and hopefully when i have a little more mouse-experience i will be able to return the favor someday....
Thx!
Mouse

Code:
```char CalcGrade(double AV){

{

if (90<= AV <= 100)
return  A;
else if (80<= AV <= 90)
return B;
else if (70<= AV <= 80)
return C;
else if (60<= AV <= 70)
return D;
else return F;
}

}```

2. Do this:

return 'A';

return A;

3. Also your if expressions are incorrect, hence the unsafe bool warning.

Try this, notice I've change some '<=' into '<'.

Code:
```if (90 <= AV <= 100)
return  'A';
else if (80 <= AV < 90)
return 'B';
else if (70 <= AV < 80)
return 'C';
else if (60 <= AV < 70)
return 'D';
else return 'F';```
You should note that if it is possible for someone to be given 101%, your function is going to assign them an 'F'.

4. ## Re: how can i express

Code:
```char CalcGrade(double AV)
{
if(AV >= 90) return 'A';
if(AV >= 80) return 'B';
if(AV >= 70) return 'C';
if(AV >= 60) return 'D';
return 'F';
}```

5. ## thanks alot guys!!

thanks so much...it's the little things that make the BIG Picture clearer!!
MUCH appreciated!
Mouse

6. Originally posted by Davros
Also your if expressions are incorrect, hence the unsafe bool warning.

Try this, notice I've change some '<=' into '<'.

Code:
```if (90 <= AV <= 100)
return  'A';
else if (80 <= AV < 90)
return 'B';
else if (70 <= AV < 80)
return 'C';
else if (60 <= AV < 70)
return 'D';
else return 'F';```
You should note that if it is possible for someone to be given 101%, your function is going to assign them an 'F'.

Nonononononono!!! You can't string logical comparisons together like that!

For example

90 <= AV <= 100

Won't check if AV is between 90 and 100

A logical operator like <= returns a boolean value (true or false).

So in actuality, what

90 <= AV <= 100

does is

90 <= AV

that will return either 1 or 0

then, it will compare that 1 or 0 with 100

So if AV was greater than or equal to 90 it would return 1, and then it would do

1 <= 100 which would return true.

Since the first expression would return either 1 or 0 the expression would always be true.

What you really want to do is make 2 separate comparisons and connect them with &&

like

if( 90 <= AV && AV <= 100 )