+ 1

If we typecast a variable in #c will it change the data type of the variable temporarily or for the whole program?

float a=2.3; int b=(int) a; now, here what will be a's data type?

25th Aug 2017, 5:57 AM
Hardeep Sinha
Hardeep Sinha - avatar
2 odpowiedzi
+ 9
You cast the float to int for that instance. The float variable remains a float variable afterwards.
25th Aug 2017, 7:15 AM
Hatsy Rei
Hatsy Rei - avatar
+ 2
Verify it using sizeof()
7th Apr 2020, 10:21 AM
kadambari.N
kadambari.N - avatar