Strlen returns the size of the string = 9 .
In the loop, it is printing one be one all the characters having the condition str[i] TRUE.
In C/C++, value 0 is false and any other value is TRUE. Also, Null character '\0' is guaranteed to have the value '0' (in the byte for '\0', 00000000 will be stored) in any character encoding that is used in the system as per C standard. So, the loop terminates at str[i] == ' \0 ' .
Output will be GATE 2016 .
PS: Statement 9 - str[length] = '\0' is unnecessary as in C all string literals are automatically given '\0' at end by the compiler. So, "GATE 2016" will be stored in memory as 'G','A','T','E',' ','2','0','1','6','\0'.