write a program that uses a function strcmp to compare two strings inputs by the user.the program should state whether the first string is less than ,equal to or greater than the second string.
write a program that uses a function strcmp to compare two strings inputs by the user.the program should state whether the first string is less than second string ,equal to second string or greater than the second string.
# include <iostream>
# include <cstring>
# include <cstdio>
usingnamespace std;
int main ()
{
// Considiring a less than b
char firstStr[30],secondStr[30];
cout << "Enter the first string -> ";gets(firstStr);
cout << "Enter the second string -> ";gets(secondStr);
if(!strcmp(firstStr,secondStr))
{
cout << "The two strings are equal" << endl;
}elseif(strcmp(firstStr,secondStr)>0)
{
cout << "The first string is greather than the second string" << endl;
}else cout << "The first string is less that the second string" << endl;
return 0;
}
Techno01 did mean that we did saw your homework description, but we saw no questions originating from you. We saw no code that you have written yourself, and thus saw no bits in it that you have difficulty with.
The purpose of exercises is that you learn, and you do learn best by doing. When you have done some, and have a concrete code problem, then we can help.
@keskiverto I agree with that tottaly and I feel shame contrubiting on such thing .I hope that he learn from this code and try to miss with it ,otherwise no good will come from it