Answer to Question #188868 in C++ for Asad

Question #188868
Write a program to compare two strings. Take both of strings from user and compare them. If equal print 1 otherwise print 0
1
Expert's answer
2021-05-07T09:03:15-0400
#include <iostream>


using namespace std;


int main(){
    //get the two stings from the user
    string s1;
    string s2;
    cout<<"Enter the first string: ";
    cin>>s1;
    cout<<"Enter the second string: ";
    cin>>s2;


    //compare the two strings
    if(s1==s2){
        cout<<1;
    }
    else{
        cout<<0;
    }


    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS