In Language C the question is Write an expression that evalu

In Language C the question is.

Write an expression that evaluates to true if and only if the string variable s does not equal end.

i am typing in..

(!s.equals(\"end\"))

but nothing is working, please help.

Solution

#include <stdio.h>
#include <stdlib.h>
#include<string.h>
int main()
{
char str1[100];

printf(\"Enter first string: \");
scanf(\"%s\",str1);
if (strcmp(str1,\"end\") == 0)
printf(\"Entered strings are equal.\ \");
else
printf(\"Entered strings are not equal.\ \");
return 0;
}

OUTPUT:
Enter first string: end
Entered strings are equal.

Enter first string: hAI
Entered strings are not equal.

NOTE:

1. In c language string comparison can be done with strcmp() function of string.h file.
2. In java equals() method can be used for equality of Object class.
3. Please mention in which language you want, you are using in wrong way((!s.equals(\"end\"))).

In Language C the question is. Write an expression that evaluates to true if and only if the string variable s does not equal end. i am typing in.. (!s.equals(\

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site