Coders Packet

Find uncommon charcaters in C++

By Subalaxmi C

Find the uncommon chatacters between two strings given by the user by using the loop concept in C++

We start with declaring the header files for the required functions we are going to be using. We've used the 'String' header file because of the function 'getline' which is to get a series of characters from the user and is declared as a string variable.

Declaration of all the required variables of both 'integer' and 'string' is done. Then we get the desired input from the users, let's call those variables 'X' and 'Y'. 

The logic here is that we take the first letter from the variable 'X' and then we compare it with all the letters of the variable 'Y'. For the comparison, we use the for and while loop.

While comparing if the letters are the same, we leave that particular letter and then move on to the next one. If the letters don't match we compare it until the end of the string, and if none of the letters matches in the end we display that particular letter in the output box.

First, we compare each letter from the variable 'Y' to the first letter in the variable 'X', then we do the vice versa. In the end, we'll know what are all the uncommon variables from the two string variable given by the user.

Download project

Reviews Report

Submitted by Subalaxmi C (SubaChidambaram)

Download packets of source code on Coders Packet