0 votes 0 votes Meenakshi Sharma asked Jul 7, 2018 Meenakshi Sharma 278 views answer comment Share Follow See 1 comment See all 1 1 comment reply MiNiPanda commented Jul 7, 2018 reply Follow Share a[0]='w' and a[5]='\0' In the 1st iteration i=0 and j=5, a[i++]=a[j--] So after the 1st loop, a[0]=a[5] and i=1 ,j=4. I.e. a[0]='\0'. When we try to print a ,since it starts with null character now so it is assumed to be the end of a string(as null character indicates the end of string). All the other characters after that won't be considered as part of a. So null string will be printed. 1 votes 1 votes Please log in or register to add a comment.
Best answer 1 votes 1 votes a[6] = 'w' 'o' 'r' 'l' 'd' '\0' after executing the loop a[6] look like as '\0' 'd' 'l' 'l' 'd' '\0' printf function stops printing the elements whenever it scans a null character. therefore output is NULL String (nothing printed) Shaik Masthan answered Jul 7, 2018 • selected Jul 7, 2018 by srestha Shaik Masthan comment Share Follow See all 2 Comments See all 2 2 Comments reply MiNiPanda commented Jul 7, 2018 reply Follow Share Shaik Masthan won't a look like ---> '\0' 'd' 'l' 'l' 'd' '\0' ? Please confirm 0 votes 0 votes Shaik Masthan commented Jul 7, 2018 reply Follow Share it's look like as '\0' 'd' 'l' 'l' 'd' '\0' is correct. previously, i mistakenly swapped them, i already updated 2 votes 2 votes Please log in or register to add a comment.