Home » C Programming » Strings

What will be the output of the program? #include #include int main() { char str[] = "India\0\CURIOUSTAB\0"; printf("%d\n", strlen(str)); return 0; }

Correct Answer: 5

Explanation:

The function strlen returns the number of characters int the given string.


Therefore, strlen(str) becomes strlen("India") contains 5 characters. A string is a collection of characters terminated by '\0'.


The output of the program is "5".


← Previous Question Next Question→

More Questions from Strings

Discussion & Comments

No comments yet. Be the first to comment!
Join Discussion