Question
void main()
{
char str[13] = "Placementadda";
printf("%s",str));
}
What will be output if you compile following c code ?
void main()
{
char str[13] = "Placementadda";
printf("%s",str));
}
Answer: Option C
Was this answer helpful ?
Size of a character array should
one greater than total number of characters in any string which it stores. In c
every string has one terminating null character. This represents end of the
string.
So in the string "Placementadda†, there
are 13 characters and they are ‘P’,’l’,’a’,’c’,’e’,’m’,’e’, ‘n’,’t’,’a’,’d’,’d’,’a’ and ‘’. Size of
array arr is 13. So array arr will store only first 13 characters and it
will note store null character.
Was this answer helpful ?
Submit Solution