answersLogoWhite

0


Best Answer

The char data type is an integral type and can therefore be used to represent integers as well as characters. However, in order to treat the representation as an actual integer, it must be explicitly converted to a non-character type, such as int.

User Avatar

Wiki User

8y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

12y ago

Because a char is an integer data type... It has a graphic representation, but it also has a numeric value, often 0 to 255, for unsigned char, and -128 to +127, for signed char.

However, programmers should not depend on the particular numeric value, or bit pattern, of a char if it is intended to represent graphical data. Doing so steps outside of the definition of proper use, and is highly non-portable.

This answer is:
User Avatar

User Avatar

Wiki User

8y ago

Characters are represented by their character encodings which are integer values. E.g., the character 'A' is represented by ASCII character code 65.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Why is char often treated as integer data type?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Can you make an integer pointer variable to char data?

Of course. But why? int *p = (int *)"string";


What are enumerated data types in pascal?

Pascal has 4 primitive data types: integer; boolean; char and; real. These 4 provide the basic building blocks for more complex types.


How do you store character and integer using structure?

Declare a structure with integer and character data members in it. Eg:struct node{int integer;char character;};Now you can use this structure definition to store the values. Eg:struct node temp;//declaringtemp.integer = 5;temp.character = 'a';


What is the default data type for Visual Basic?

A variable has a data type such as integer, string, double. A data type tells the variable to only store values that are a particular data type, so you can only store numbers without decimal points in an integer variable, and only characters such as "ABCD" in a string variable.


Why java not use int as a generic argument?

Only Objects can be used as generic arguments. Primitives Data Types (int, long, char ...) are not objects. But you can use Integer, an Object that wrap the data type int instead.


Can a pointer to char data-type be type casted to pointer to integer type?

Yes it is possible in C language.includeint main(void) { char *cptr; int *iptr; iptr=(int*)cptr; return 0; }If you find the info useful Please Vote!!!


What data type is age?

integer data type


What is size of char far data type?

char is a primitive data type and depends on the programming language and the operating system.


What is difference between '1' and 1 as for us a computer is concerned with respect to c plus plus?

When you type '1' in a C++ program, it is considered to be of character data type(char). When you type 1, it is considered to be of integer data type.


What is turbo c variables?

Turbo C variables are memory place holders for storage of data during the execution of a Turbo C program. Types of variables include integer, real and char.


What is a valid variable data type?

1. If its natural or integer numbers- Integer(Int) data type. 2. If it consists of decimal or fraction part- Double or float data type. 3. If it has a single letter or sign- Character(Char) data type. 4. If its got many words(alpha-numerical)- String data type. 5. If the result has to be "true" or "false"- Boolean data type.


How char data type is represented in the memory?

The char data type is a single 16-bit, unsigned Unicode character. It ranges from 0 to 65,535. They are not integral data type like int, short etc. i.e. the char data type can't hold the numeric values. The syntax of declaring a char type variable is shown as:char caps = 'c';