Here's one of the problems with your code:
Code:
for (int j=0;j<=t;j++)
{
     tot =d[j];
     cout<<setw(9)<<j<<setw(13)<<tot<<endl;
}
 
for (int s=j;s<=arraysize;s++)
{
     cout<<setw(9)<<s<<setw(13)<<tot<<endl;
}
Because you declared j in the first for loop, it can only be accessed in that for loop. Declare it within main with your other declarations if you plan on using it again.

Oh, and do you really need an array for this? I think you could code this with just one for loop.