Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hint: The variables enclosed in parenthesis in the mathematical definition are c

ID: 3537810 • Letter: H

Question

Hint: The variables enclosed in parenthesis in the mathematical definition are calls to the C() function.


Output: The output for the program should appear as follows:


C(6, 2) is 15

C(8, 3) is 56

C(14, 8) is 3003

C(21, 3) is 1330

C(45, 5) is 1221759

Press any key to continue.



Below is what I have so far.



#include "stdafx.h"

#include <iostream>

#include <stdlib.h>

#include <stdio.h>


using namespace std;


int C(int n, int k);


int main(int argc, char **argv)

{

cout << "C(6, 2) is " << C(6, 2) << endl;

cout << "C(8, 3) is " << C(8, 3) << endl;

cout << "C(14, 8) is " << C(14, 8) << endl;

cout << "C(21, 3) is " << C(21, 3) << endl;

cout << "C(45, 5) is " << C(45, 5) << endl;


cout << endl << "Press any key to continue." << endl;

getchar();


return 0;

}


int C(int n, int k)

{

if (n == k)

return n;

else if (n > k)

return C (n * k, n);

// return C (n-k, k);


int value = 0;


// TODO: implement the detials of the function int C(int n, int k)

  

// return value;

}

Explanation / Answer

its a n choose k problem. the values represents selecting k out of n.c(6,2) represents choosing 2 out of 6.so here just write c(int n, int k)as c(int n, int k){ if k == 0 return 1; else if n == k: return 1; else return c(n-1, k-1) + c(n-1, k); }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote