In some situations. it becomes necessary to force a type conversion which is different from the automatic conversion done by C. We are required to
explicitly convert a value of a particular expression to a specific data type. This is where, local conversion of a data type.This is where, local conversion
of a data type is done which is known as type casting. The general form of casting a value is:
(type-name) expression
type-name is one of the standard data types of C. The expression can be any valid C expression viz., a constant, variable or expression. The
parenthesis around the type name are essential. The value of the expression, undergoes the type conversion due to type casting. Some example of type casting:
a=(int)9.2
With type casting the fractional part will be truncated and the result will be 9.
int i=9, j=2;
float p;
{
p=(float) i/j;
}
How to set div beside each other ?
14 years ago
No comments:
Post a Comment