How to?

closed account (ENhkSL3A)
Okay so I'm writing a code for school again and my teacher said,"The ASCII code for π is 227."
Well apparently on the mac it isn't OR I'm once again not doing things right.
So my question is on the mac what do I write in my code to display the pi symbol?
Would I put char(227) because when I did and I ran my code in the terminal it just showed a question mark in char(227)'s place.

char n(227) would be truncated. 227 is too large to be held in a signed char. It can be held in an unsigned char, in which case it would be the lowercase Pi symbol.

 
unsigned char pi(227);
my teacher said,"The ASCII code for π is 227."

Well, your teacher is wrong. The ASCII code for n is 110.
http://www.asciitable.com/
The ASCII code for n is 110.

OP used the lowercase pi symbol, not n, which has an extended ASCII value of 227.
closed account (ENhkSL3A)
Hahaha, AbstrationAnon, she's been wrong a lot lately!! >:( Thanks to both of you guys! :)
ASCII's full form is American Standard Code for Information Interchange... its standard

But since http://www.asciitable.com/ shows that pi is in extended ASCII code maybe your compiler doesn't supports it... what compiler/IDE are you using?
closed account (ENhkSL3A)
Geany and yeah I think that may be the problem but I defiantly got it to work by declaring it with 'unsigned char pi(227);' :)
ooh! char will just give you values from -127 to +127, but unsigned char will give you values from 0 to 255; that's why your problem was solved...
+1

If you instructor hadn't mentioned that, I'd mention to your instructor that an unsigned char needs to be used.
closed account (ENhkSL3A)
I thought about it but she's a 'know it all' type... The ones that act like you're horrible for trying to help them when they make a mistake in the instructions.. EVEN when you do it nicely. -.- lol
Topic archived. No new replies allowed.