Multiple choice technology programming languages

What value will "strcmp("Astring", "Astring");" return?

  1. A positive value

  2. A negative value

  3. Zero

  4. Compile Error

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

strcmp() returns zero when both strings are identical. Any non-zero value indicates the strings differ, with the sign indicating which string comes first lexicographically.

AI explanation

To answer this question, you need to understand the function strcmp() in C.

The strcmp() function is used to compare two strings in C. It returns an integer value that indicates the relationship between the two strings.

In this case, the strcmp("Astring", "Astring") compares the string "Astring" with itself. Since the two strings are identical, the strcmp() function will return 0.

Therefore, the correct answer is C) Zero.