Before you access num[1], you need to be sure that the vector contains at least two elements.
At line 14, if the user enters a positive integer, it is stored in the vector. Then the loop terminates, containing just one element. Under that condition, you will get an error when accessing the second element.
while ( d < 2)
{
int another_variable_that_it_is_not_the_counter_of_the_loop;
cin >> another_variable_that_it_is_not_the_counter_of_the_loop;
num.push_back (another_variable_that_it_is_not_the_counter_of_the_loop);
d++;
}