# char

• 10-24-2001
K&J
char
Hello,
I would like to know what char does and is. I know it is a variable, used to hold a value that are assigned to it. Although in the book I am useing it says, "if "a" is an int, "b" is a double, and "c" is a char, what is the type of value returned by the expression a + c?:confused:
• 10-24-2001
Engineer
Well, since a is an integer, and c is a character, where character is represented by its integer value the expression of a+c would give the integer value of a plus the integer value of the character stored in c.

Hope this helps.
• 10-24-2001
Engineer
Example:

a = 10;
c = 'A'; // integer value of A is 65

b = a + c; // here 'b' = 75 = 65+10

Cheers,
• 10-24-2001
Unregistered
Lte's say that I am a supernatural mathematician. I can do things with numbers faster than most people can believe. However I can't speak, recognize letters, etc. How could you, or anyone else, communicate with me?

One way would be to agree on a mathematical code that substitutes a numeric value for each letter. Let's say that capital A was represented by the integer 0 and each successive capital letter was one integer higher. Lower case letter a would be 27 and each successive lower case letter would be one integer higher. Then we could do the same thing for other symbols like the numbers 0-9, the various punctuation marks, and even other symbols like dollar signs, asterisks, mathematical signs for addition, subtraction; really just about anything we could think of. Now we can convert back and forth without any trouble using this conversion process.

Now let's take it one step more. Suppose I can deal only with binary, not decimal numbers. No big deal really, just convert all decimal numbers into binary and back again as needed. Kinda cool, actually.

Turns out that's not too far off from what happens with the computer. The memory area's within the computer can be viewed as a long series of mailboxes, each of which can be found at a very specific location, or address, and each of which can have either one of two states, say maybe full or empty, or you might prefer on or off, or maybe right or left, or maybe even zero or one. Whatever, doesn't really matter. The point is that these two states can be thought of as the equivalent of the zero or one used in binary math. Hence you could use a given sequence of memory to represent binary numbers. All you have to do is agree that a given amount of memory will be used to store a given piece of information. The word bit is often used to mean a given "mailbox" in memory. It represents the smallest piece of useable information. Eight bits represent a byte. This means that if you let each char represent eight bits (or one byte) of information you could store up to 256 (that is 2^8) different chars, which is plenty for most of the symbols used in routine english (and many other languages). It turns out large groups of people have agreed to accept a given conversion table, called ASCII character set, that converts english characters/symbols into decimal and binary equivalents so they can manipulate the pattern of storage in the computer to do useful things. Thus each time you type a given character on the keyboard the computer changes it into a decimal and a binary number and does something with it. This means you can actually do crazy things like adding 3 + Z to get 91 (or some such number) or something like C++ (which gives D), even. Each char has a given decimal and binary equivalent there for you to manipulate if you wish. Often we don't bother, but some people can do some pretty funky things by twiddling the bits underlying the chars/symbols, etc you and I routinely use.
• 10-24-2001
lmov
Quote:

"if "a" is an int, "b" is a double, and "c" is a char, what is the type of value returned by the expression a + c?
By the rules of integral promotion the expression evaluates to an int.
• 10-24-2001
Troll_King
Quote:

I would like to know what char does and is. I know it is a variable, used to hold a value that are assigned to it.
I actually screwed you up on this a couple days ago. I tried to clear it but was not specific. A char is not a variable, but instead it is a 'data type'. Furthermore it is a 'primitive' or 'built in' data type. It is used to define an instance of an object or in simple terms a variable. The variable can than store data values according to its data type.

The statement you are asking for is incomplete. A statement requires an lvalue.
Code:

```lvalue assignment operator  operand  math operator  operand ?              =              a          +            c;```
The result will be influence by the lvalue. You didn't state any lvalue, but the right hand side will evaluate into an integer. People explained that part.