#include<iostream.h>
#include <iomanip.h>
#include <signal.h>
#include <stdlib.h>
#include <time.h>
void signal_handler(int);
int main()
{
signal(SIGINT,signal_handler);
srand(time(0));
for(int i=1;i<101;i++)
{
int x=1+rand()%50;
if(x==25)
raise(SIGINT);
cout<<setw(4)<<i;
if(i%10==0)
cout<<endl;
}
return 0;
}
void signal_handler(int signalValue)
{
cout<<"\ninterupt signal ("<<signalValue<<" ) received. \n"<<"Do you wish to continue(1=yes or 2=no)?";
int res;
cin>>res;
while(res!=1 && res!=2)
{
cout<<"(1=yes or 2=no)?";
cin>>res;
}
if(res==1)
signal(SIGINT,signal_handler);
else
exit(EXIT_SUCCESS);
}