Computer Science, asked by kaursehmi4532, 6 months ago

what do u mean by type concersion? why we need this concept? explain with an example​

Answers

Answered by hilalahmadwani1
0

Answer:

Typecasting, or type conversion, is a method of changing an entity from one data type to another. It is used in computer programming to ensure variables are correctly processed by a function.

Typecasting, or type conversion, is a method of changing an entity from one data type to another. 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 string. This might be done in order to compare two numbers, when one number is saved as a string and the other is an integer. For example, a mail program might compare the first part of a street address with an integer. If the integer "123" is compared with the string "123" the result might be false. If the integer is first converted to a string, then compared with the number in the street address, it will return true.

Typecasting, or type conversion, is a method of changing an entity from one data type to another. 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 string. This might be done in order to compare two numbers, when one number is saved as a string and the other is an integer. For example, a mail program might compare the first part of a street address with an integer. If the integer "123" is compared with the string "123" the result might be false. If the integer is first converted to a string, then compared with the number in the street address, it will return true.Another common typecast is converting a floating point number to an integer. This might be used to perform calculations more efficiently when the decimal precision is unnecessary. However, it is important to note that when typecasting a floating point number to an integer, many programming languages simply truncate the decimal value. This is demonstrated in the C++ function below.

Similar questions