answersLogoWhite

0

An int and a char are both integral types such that a char is always guaranteed to be within the range of an int, because an int is at least as long as a short which is at least as long as a char (in bits). Converting the other way, from int to char, is not guaranteed to work, but we can guard against this by testing the int value is within the required range prior to conversion.

The reason we use an int as opposed to a char in certain cases is because an int can represent values that a char cannot. This is useful in functions which would normally return a char value, but where we also need to cater for other values. Those other values could be used to indicate an error condition, for instance.

User Avatar

Wiki User

7y ago

What else can I help you with?

Related Questions

What is the data type int?

Data-type (short for integer).


What defines a data type?

the type of data which we store in a variable.. example: int a=10; /*here a is variable (data) which is of type int and stores a value 10.*/


What is int in 'c' language?

data-type


Explain the basic datatypes in C?

C datatype can be categories into two part 1) Scalar data type 2) derived data type.. The scalar data type is also called basic data type they are int char float double long signed or unsigned are key word which effectively change the storing power of these data type. by default they are signed in nature..


Suggest the data type that can be used for initializing alphanumeric elements in a c programmed array .Also tell you the compiler that can understand the data type.?

Data Type : - It is used to identify the type of data. 'C' Language has a large no of data type, Thus it is also known by rich data type language: Data type are generally classified in three group: 1: Fundamental data type 2 Derived Data Type : 3 Use defined data type; 1 Fundamental data type: Fundamental data type includes i) The int data type: The data type int can store integer value only for eg. 14, 45, 78 declaration: int a,b; here we can store any value in variable a & b. ii) Char Data Type : The data type char can store character value only which is enclosed with single quote for e.g. 'c' declaration : char x = 'c' iii) Float Data Type:


What is data type and field name?

Data Type defines the type of data that will be stored. Example : int, byte, short etc


How do you make an array of 56?

In Java:int[] myArray;// or: int myArray[]followed by:myArray = new int[16];Instead of int, you can use any other data type, including a class.


Explain any three data types in C?

Int.,Float.Double,Character


What is the abbrevations for int?

"int" is the abbreviation for an integer data type. In Java an int is specifically a 32-bit signed integer.


What is the different type of data type in c classified it?

float,int,char


What are the valid type of data that the main can return in c language?

Type 'int'


Where string is primitive data type of string data type?

String is not primitive data. Only char,int,double,and boolean are!