Quantcast
Channel: C - Codecademy Forums
Viewing all articles
Browse latest Browse all 25

Learn C: Variables and Operators. VARIABLES: LESSON Casting Types Continued

$
0
0

https://www.codecademy.com/courses/learn-c-variables-and-operators/lessons/variables-c/exercises/casting-types-continued

//I have a silly question :) //I understand this line: targetChar = (char)sourceInt; /*that targetChar wasn't declared and has no value in it unless we cast the sourceInt with a (char). But what I do not understand is that why do we not have to do the same for the very next line:*/ targetChar = sourceDouble; /*Why do we not have to add a cast (char) with the sourceDouble? And what is the difference between */ targetChar = sourceDouble; //and, targetChar = (char)sourceDouble; /*They both give us 7 anyway, but I do not understand why.*/

2 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 25

Trending Articles