HOW TO IMPLEMENT TYPE CASTING IN C? by Bits Bytes

0

What is Type Casting in C-language?
Type Casting means to change the variable into one data type to another data type. If the compiler will automatically change one data type to another data type. or you can forcefully change one data type to another data type.


Why need to Type Casting in Computer Language?
Every Computer language having type conversion or TYPE CASTING service available. It is used in computer programming to ensure variables are correctly processed by a function. An example of typecasting is converting an integer to a character. This might be done in order to compare two numbers when one number is saved as a character and the other is an integer

There are 2 types of Type Casting:-

1.) Implicit Type Casting:- In this type of typecasting we do convert the data type into one to another but also store that converted value in a variable of the corresponding data type. It handles by the compiler.
Syntax

int main()
{
int a;
float b=10.34;
a=b; //Implicit type casting

}



2.)Explicit Type Casting:- In this type of typecasting we do convert the data type for a particular set of instructions. It is forcefull type cast by the programmer
Syntax

int main()
{
int a;
float b=10.34;
a=(int)b/2; //Explicit type casting Only for this instructions b act as Intger not float


}
Practical Video

Coding:---  Code.

Post a Comment

0Comments

We you have any doubt let me know :)

Post a Comment (0)
To Top