Sail E0 Webinar
Question

What will be output if you compile following c code ?


void main()
{
char str[13] = "Placementadda";
printf("%s",str));
}


Options:
A .  Placementadd
B .  P
C .  Garbage Value
D .  Compile Error
Answer: Option C


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 ?
Next Question

Submit Solution

Your email address will not be published. Required fields are marked *

Latest Videos

Latest Test Papers