Logo 
Search:

C++ Programming FAQ

Submit Interview FAQ
Home » Interview FAQ » C++ ProgrammingRSS Feeds

What will be the output of the mentioned code?

  Shared By: Irmgaard Miller    Date: Mar 19    Category: C++ Programming    Views: 679

Answer:

5. Consider the following code segment:
void main()
{
int a,b;
string s1("aabbcc");
string s2("bbccaa");
a = s1.compare(4,2,s2,2,2);
b = s1.compare(0,2,s2,0,2);
if(a == 0)
cout<<"Equal , ";
else
cout<< "Not equal ,";
if(b ==0)
cout<<"Equal";
else
cout<<"Not Equal";
}

What will be the output of the above code?

Options

a) Not Equal , Equal
b) Not Equal , Not Equal
c) Equal , Equal
d) Equal , Not Equal

Answer : d) Equal , Not Equal

Share: 
 

Didn't find what you were looking for? Find more on What will be the output of the mentioned code? Or get search suggestion and latest updates.


Your Comment
  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].


Tagged: