Here is a program which ends before execution of main( ) function starts but still manages to get the output.
Basically all global objects are created before entering into main(); So you can write any code into the constructor of objects, which will be called whenever object is created.
class A
{
public :
A( )
{
cout << “In A” ;
exit( 1 ) ;
}
} ;
main( )
{
cout << “not reached” ;
}
A a ;