String and integer value in c/c++

char str1[]=”helloo”;
printf(“%d”,str1);
Answer:-18


Whenever It convert form string to integer
First charcter contain -12
Second character :-14
Third and forth:-16
Fifth and sixth :-18
char str1[]=”helloo”;
printf(“%d”,str1);
Answer:-18
separate string
char str1[]=”h”;
char str2[]=”e”;
char str3[]=”ll”;
char str4[]=”oo”
printf(“%d%d%d”,str1,str2,str3,str4);

Answer:-12,-14,-18,-22
You think output is like -12,-14,-16,-18 but not like that it will consider like that



Related post