The initializers in the array are character literals, not int
values so the array will be populated with the numeric value of each character literal (multibyte character literals, such as '32'
, are permitted but their value is implementation defined, see How to determine the result of assigning multi-character char constant to a char variable?).
To get the desired output use int
literals:
int arr[]={1,2,4,8,16,32,64,128};