+ 5

Anyone know what is type conversion I am not understand that???? (String or float)

2nd Mar 2020, 11:45 AM
Alisha
Alisha - avatar
2 Réponses
+ 4
Type conversion is to convert one type to another type For example You have input a number (suppose 15 and suppose it is age of any people ) and you want to check input age is less than 18 or not. Here the input will take string value (NOTE --> collection of characters "s" is single character "hello" is string. Anything inside double quotes or single quotes is string for example "15"). Here 18 is an integer value and 15 is string value, if you check condition directly the interpreter will generate an error that is why we need to convert "15" (string) to 15 (int) SYNTAX variable_name = input("Enter your number") variable_name = type(variable_name) To convert string to integer value variable_name = int(variable_name) To convert string to float value variable_name = float(variable_name)
2nd Mar 2020, 12:33 PM
Sujan Kharal
Sujan Kharal - avatar
+ 1
The type conversion process in C is basically converting one type of data type to other to perform some operation. The conversion is done only between those datatypes wherein the conversion is possible ex – char to int and vice versa.
3rd Mar 2020, 6:43 AM
A S Raghuvanshi
A S Raghuvanshi - avatar