172k views
0 votes
What does this call to strcmp return?

x = strcmp( "ABCD", "XXX" );



A.1



B. Something > 0



C.-1



D. 0



E.Something < 0

1 Answer

6 votes

Answer:

The correct for the given question is option(c) i.e .-1.

Step-by-step explanation:

Strcmp() function is used to compare the two string .it compare the string character by character strcmp() function return the three value on comparison.

(1) if string 1 is equal to string 2 it return 0;

(2) it return>0 if string1 has greater ASCII value than string 2

(3) it return <0 if string1 has smaller ASCII value than string 2

In the given code strcmp returns -1 value the ASCII code of character 'A' has smaller then ASCII code 'X';

Following are the program of given code

#include<stdio.h>// header file

#include<string.h>

int main() // main method

{

char x;

x =strcmp( "ABCD", "XXX" );

printf("%d",x);

return 0;

}

Output:-1

User Typeseven
by
6.3k points