Doubt in type casting videos in c++

according to the previous video
float a = 15/5 will give output as 3
now according to this video
char ch = ‘A’ + 2 will output ‘C’

for both the cases type should be the left hand sides variable , what should we follow now?

Hi @Bond007
The left hand side determines the type of variable.
3 or 3.0 both comes under float and if the decimal part of a float is 0 it skips the decimal part.
if you write float a = 3.0
then output a would give 3 only.

Hope this helps
Give a like if you’re satisfied :slight_smile:

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.

i have one doubt , is it better to give explicitly the type ?

It depends on type you want in the output and in calculation.