#include <iostream.h>

#include <stdlib.h>

class fraction

{

// Your stuff here

friend ostream &operator<<( ostream &stream, const fraction &frac);

};

ostream &operator<<( ostream &stream, const fraction &frac)

{

stream << frac.num << '/' << frac.dem << endl;

return stream;

}

void main(void)

{

fraction f1(2,4);

cout << f1;

}

OUTPUT: 2/4

PS. Delete the other 3 Q that are the same as this one

#include <stdlib.h>

class fraction

{

// Your stuff here

friend ostream &operator<<( ostream &stream, const fraction &frac);

};

ostream &operator<<( ostream &stream, const fraction &frac)

{

stream << frac.num << '/' << frac.dem << endl;

return stream;

}

void main(void)

{

fraction f1(2,4);

cout << f1;

}

OUTPUT: 2/4

PS. Delete the other 3 Q that are the same as this one