1/7
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
Implicit
Data Type Conversion: 0.5 / 2;
Usually when smaller data type is converted to large to prevent data loss.
Explicit
Data Type Conversion: (int)
Manually converts one data type to another using the cast operator (). It is used when there is a possibility of data loss, or when the compiler cannot perform the conversion automatically.
Assignment
Data Type Conversion:
int Volume;
float triangle;
volume = triangle/ 2;
The one where there is promotion( if variable has higher than expression to the right) and demotion( if variable has lower than expression on the right). Whatever the variable data type is on left is what the data type of the expression on the right will be converted to.
%{width}.{precision}{size}{conversion code}
What is each part of this: %2.4lf
width modifier
Is used to specify the minimum number of positions to reserve for the output of a value
precision modifier
For the number of decimal places being placed. won’t work for int
Conversion Code
They are the type you want your value to be printed as such as char(c), int(d), and float(f)
Size Modifier
They are how long or short you want your value to be such as h for short or l for long. In lf for double, l would be this while f represents float. Ex: %2.4lf