Logo 
Search:

C++ Programming FAQ

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

What will be the output of the code mentioned in description if there is no compile error?

  Shared By: Millie Brown    Date: Jul 07    Category: C++ Programming    Views: 585

Answer:

Consider the following code segment:
void main()
{
list <int> l1;
list <int> l2;
l1.push_front(6);
l1.push_back(8);
l1.push_front(4);
l1.push_back(5);
l1.push_front(3);
l1.reverse();
l1.front()=l1.front()*5;
l2=l1;
cout<<l1.front()<<" ";
cout<<l2.back();
}

What will be the output of the above code if there is no compile error?

Options

a) 25 3
b) 16 4
c) 9 8
d) 36 5

Answer : a) 25 3

Share: 
 



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


Tagged: