Question: 2 . Write a ( mathbf { C + + } ) function that receives two integer parameters ( mathbf

2. Write a \(\mathbf{C ++}\) function that receives two integer parameters \(\mathbf{n}\) and \(\mathbf{r}\) and returns the permutation of the two numbers as given by the following equation:
\[
{}_{r}^{n} P=\frac{n!}{(n-r)!}
\]
The main function should prompt the user to enter two integers and call the permutation function to get the result and display it on the console only when the two integers are nonnegative. Otherwise, the main function displays a warning message. Notice that \(\mathbf{n}\) is always the larger number.
\begin{tabular}{|l|l|}
\hline \multicolumn{1}{|c|}{ Sample Output 1} & \multicolumn{1}{c|}{ Sample Output 2}\\
\hline Enter two integers: 53 & Enter two integers: 04\\
The permutation \(=60\) & The permutation \(=1\)\\
\hline \multicolumn{1}{|c|}{ Sample Output 3} & \multicolumn{1}{c|}{ Sample Output 4}\\
\hline Enter two integers: -97 & Enter two integers: 66\\
Wrong Input! & The permutation \(=720\)\\
\hline
\end{tabular}
2 . Write a \ ( \ mathbf { C + + } \ ) function

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!