Knowee
Questions
Features
Study Tools

If two strings are identical, then what will be the return value of strcmp() function?Select one:0-11

Question

If two strings are identical, then what will be the return value of strcmp() function?Select one:0-11

🧐 Not the exact question you are looking for?Go ask a question

Solution

The strcmp() function in C programming language is used to compare two strings. If the two strings are identical, the strcmp() function will return 0. This is because strcmp() compares two strings character by character. If the ASCII value of the first unmatched character is less than the second one, the function returns a negative value. If the ASCII value of the first unmatched character is greater than the second one, the function returns a positive value. But if the two strings are identical, there are no unmatched characters, so the function returns 0.

This problem has been solved

Similar Questions

What does the strcmp() function return when both the strings are equal?

What will strcmp() function do?Select one:a.compares the first n characters of the objectb.compares the stringc.undefined functiond.copies the stringClear my choice

Which of the library function is managed to compare two strings ?a.strlenb.strcatc.strcmpd.strcpy

Which function is used to compare two strings lexicographically in C++?compare()equals()strcmp()strcomp()

Which one of the following statements is correct?Select one:strcmp(s1, s2) returns 0 if s1==s2strcmp(s1, s2) returns 1 if s1==s2strcmp(s1, s2) returns a number greater than 0 if s1<s2strcmp(s1, s2) returns a number less than 0 if s1>s2

1/2

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.