type casting code example
Example 1: type change in c
#include <stdio.h>
main() {
int sum = 17, count = 5;
double mean;
mean = (double) sum / count;
printf("Value of mean : %f\n", mean );
}
Example 2: java type casting
int SomeNumber = 5;
double WideCastedNumber = (double)SomeNumber;
double SomeNumber = 5.39;
int NarrowCastedNumber = (int)SomeNumber;
Example 3: cast java
JAVA: Example of cast:
int SomeNumber = 5;
double WideCastedNumber = (double)SomeNumber;
double myDouble = 9.78;
int myInt = (int) myDouble;
Example 4: typecasting java
Assigning a value of one type to a variable of another type is
known as Type Casting.
Auto-boxing; is a process when you take a primitive value and
assign into wrapper class object.
Un-boxing; is a process when you take Wrapper class object
and convert to primitive.
Example 5: what is typecasting
Assigning a value of one type to a variable of another type is
known as Type Casting.
Auto-boxing; is a process when you take a primitive value and
assign into wrapper class object.
Un-boxing; is a process when you take Wrapper class object
and convert to primitive.