Welcome to the CSC Q&A, on our server named in honor of Ada Lovelace. Write great code! Get help and give help!
It is our choices... that show what we truly are, far more than our abilities.

Categories

+19 votes
asked in CSC211_Winter2018 by (1 point)

3 Answers

+9 votes

Yes, we can.
This is an example of how you convert:
int i = 3; // i is 3
double d = (double) i; // d = 3.0

answered by (1 point)
+2

Is it the same for the other way to int?

+2

yeah, just switch their places

+4 votes

Yes when a variable type is being changed (while it is legal) it is called casting.

You can cast a variable with the structure of

= () . Read the line above without the <>. To select what you want to cast, you should also put a ( ) around the part you want specifically to be casted.
answered by (1 point)
+4 votes

Yes by casting the variable. You can put (int) in front of the variable

answered by (1 point)
...