Character array size

in the video,when the instructor print the size of character array s1 we are getting garbage values appended to “hello” which gives “helloabcde” but the size of s1 comes out to be 5.How is size of s1 is 5?why is size not taking the length of garbage value and null character after “hello”

size function does not consider garbage values. It will only consider the characters you have initialized it with.
Refer this discussion Why is that the sizeof a,b,c,d,e isn't been counted?