Compare two string

#include <iostream>
#include <string.h>
#include <bits/stdc++.h>

using namespace std;

void compare(string s1, string s2){
    if(s1 != s2){
        cout<< s1 << " is not equal to "<< s2 <<endl;
        if(s1 > s2){
            cout << s1 <<" is greater then "<<s2<<endl;
        }
        else{
            cout<< s2 <<" is greater then " << s1 <<endl;
        }
    }
    else
        cout<< s1 << " is equal to " << s2 <<endl;
}
int main(){
    string s1("ocean");
    string s2("labz");
    compare(s1,s2);
    string s3("OceanLabz");
    string s4("OceanLabz");
    compare(s3,s4);
    return 0;
}

    Leave a Reply

    Your email address will not be published.

    Need Help?