0 votes 0 votes output of the following program? #include<stdio.h> int main() { char arr[10]; arr = "world"; printf("%s",arr); return 0; } Why compilation error in this program , explain briefly? Siddharth Bhardawaj asked Jul 25, 2018 Siddharth Bhardawaj 2.0k views answer comment Share Follow See all 3 Comments See all 3 3 Comments reply Shaik Masthan commented Jul 25, 2018 reply Follow Share arr is name of array....therefore it can't be use as lvalue, due to this compilation error. for removing that, combine these statements char arr[10]; arr = "world"; as char arr[10] = "world"; 2 votes 2 votes Naveen Kumar 3 commented Jul 25, 2018 reply Follow Share @ Shaik Masthan can you explain why https://ideone.com/GAMla3 is giving undesired o/p. while, https://ideone.com/dFqTs0 is working fine. 0 votes 0 votes Shaik Masthan commented Jul 25, 2018 reply Follow Share in first code.. char arr[10]; arr[10] = "world"; it is wrong... arr[10] is a character variable, so you have to give character, otherwise it will generate warning but not compilation error due to memory address which is return by string constant "world" looking as integer if your code is char arr[10]; arr[10] = 'w'; then you are making the index 10 of arr is character 'w'.... but note that you didn't initialize the elements of arr (arr[0],arr[1],...) due to this you are getting garbage printing... in second code, you written that char arr[10] = "world"; ---> initializing the array ===> correctly print 1 votes 1 votes Please log in or register to add a comment.