Hi Sir,

Will you please clarify me how can we specify signed and unsigned char in C and C++?

Thanks in Advance.

Hello Murali, thank you for the question.

In the C and C++ languages, all variables are signed by default. In order to specify that to be unsigned (cannot hold a negative value, which doubles the amount of positive values the variable can be), you simply use the unsigned keyword.

char c; // Creates a signed variable of type char, which can values between -128 and 128;

unsigned char b; // Creates an unsigned variable of type char, capable of storing values between 0 and 255.

As you can see, both variables can store the same number of values, with the only difference being that signed happens by default, and includes negative numbers.

I hope this information was helpful.

- Eddie


All Answers

Answers by Expert:

Ask Experts




I can answer questions about the C++ language, object oriented design and architecture. I am knowledgable in a lot of the math that goes into programming, and am certified by ExpertRating.com. I also know a good deal about graphics via OpenGL, and GUIs.


I have completed numerous games and demos created with the C++ programming language. Currently employed as a software engineer in the modeling and simulation field. I have about 7 years experience.

©2017 About.com. All rights reserved.