Yesterday I went for an interview where I have been asked to create a program to find largest and smallest among 5 numbers without using array.
I know how to create
You could use list (or vector), which is not an array:
#include
#include
#include
using namespace std;
int main()
{
list l;
l.push_back(3);
l.push_back(9);
l.push_back(30);
l.push_back(0);
l.push_back(5);
list::iterator it_max = max_element(l.begin(), l.end());
list::iterator it_min = min_element(l.begin(), l.end());
cout << "Max: " << *it_max << endl;
cout << "Min: " << *it_min << endl;
}