QUIZ 63

What is the output ?

int main()
{
char a[100]={‘H’,’E’,’L’,’L’,’O’,”,’W’,’O’,’R’,’L’,’D’,”};
printf(“%d”,strlen(a));
return 0;
}

a) 100
b) 10
c) 12
d) 5

Answer : (d)

Explanation :

C reads strings as char array terminated by ”. strlen() returns the length of string, so it returns as the length of HELLO as it encounters the first ” after HELLO.

Leave a Reply

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