Write a program to compute the value of a given position in Pascal's Triangle (See image).
The way to compute any given position's value is to add up the numbers to the position's right and left in the preceding row. For instance, to compute the middle number in the third row, you add 1 and 1; the sides of the triangle are always 1 because you only add the number to the upper left or the upper right (there being no second number on the other side).
The program should prompt the user to input a row and a position in the row. The program should ensure that the input is valid before computing a value for the position.
i have this much done, stuck what i have to do next
1 2 3 4 5 6 7 8 9 10 11
int main()
{
int row, position;
cout<<"Please input a row and a position along the row: ";
cin>>row>>position;
if(row<position)
{
cout<<"Invalid entry. Position must be less than or equal to row.";
return 0;
}
cout<<"Value at row "<<row<<" and position " <<position<<" is "<<compute_pascal(row, position);