Finding Common Alphabet Between Two Names in C++/C

After getting more than 800 Hits to my previous post that is to find common alphabets between ‘AMITABH BACHCHAN’ and ‘RAJNIKANTH’ today I am going to post the code for finding common alphabets in C++. This work is done by my junior Ankit . He is in just 1st year. So I really appreciate his work and hope you will also like his codes. I am just posting on behalf of him. All credits goes go Ankit .

We have two names, say “AMITABH BACHCHAN ” and “RAJNIKANTH”. Our work is find common alphabet in these two names. The answer would be ‘AITHN’. i have written my code, if you find your code, more easier than mine, please do write in comment box. So lets go!

You can check the solution here.

using namespace std;
int main()
    int len1, len2, x;
    string s1="AMITABH BACHCHAN", s2="RAJNIKANTH", s="";
    //if you want to take two names from the users then just define
    //string s1,s1,s="";
    //and remove the '//' from below lines.
    len1= s1.length();
    len2= s2.length();
    for(int i=0;i<len1;i++)
        for(int j=0;j<i;j++)
            x= 1;
        for(int k=0;k<len2;k++)
                cout<<s1[i]<<" ";
    return 0;

Thank You.
If you liked this article, please rate and comment. Thank You!


Deepesh Singh
You may also like.

Windows 8 App Store Internet on Windows Phone Influence of Online Social Networks C Program

2 thoughts on “Finding Common Alphabet Between Two Names in C++/C

Please leave your valuable comment.

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s