Why is my code failing a test case?

Hello Isha, take input as cin>>s1>>s2, rest is all fine.

can you tell what is the problem with my using a getline() function and how does using cin helps?

Sure, see the input format
Testcases(\n)
string1(space)string2(\n)
string1(space)string2(\n)
…
so use cin.get() only once after testcases
then use
getline(cin,s1,’ ');

getline(cin,s2,'\n');

here is the code https://ide.codingblocks.com/s/321398