set> dst;
dst.insert(20);
dst.insert(30);
dst.insert(10);
dst.insert(50);
dst.insert(10);

set :: iterator itr;
for(itr = dst.find(40); itr != dst.end(); itr++)
cout << *itr << \" \"; [/sourcecode]

(A) 40
(B) 50
(C) 30
(D) None of these


Answer: (D)

Explanation: find(val): returns an iterator to the element(val) if present in the set else returns iterator to the end.
Here 40 is not present so iterator reaches to the end hence *itr returns no output.

Quiz of this Question


  • Last Updated : 19 Nov, 2018

Share your thoughts in the comments