Hi, i was wondering if i could get some help on a program i am working on for my c++ class. i don't know how to do functions for the factorial function. any help would be really appreciated. i will post the code of what i have so far below.
#include <iostream>
usingnamespace std;
//Add function prototypes here.
double permut ( double temp1, double numCol)
{
return temp1 * numCol;
}
double precombs ( double temp2, double numSel)
{
return temp2 * numSel;
}
int main()
{
//Declare variables here.
double numCol; //n = number of items in a collection.
double numSel; //k = number of items to be selected from the collection.
double perms; //P = number of permutations.
double combos; //C = number of conbinations.
double precombo;
double temp1 = 0;
double temp2 = 0;
//Ask for user inputs.
cout << "Please enter the number of collection itens (< 35): ";
cin >> numCol;
cout << endl;
cout << "Please enter the number of selected collection items (< 35): ";
cin >> numSel;
cout << endl;
perms = 1;
precombo = 1;
//Calculates the number of possible permutations.
{
for (temp1 = numCol; temp1 != 0 ; --temp1)
perms *= temp1;
}
//Calculates the number of different orderings for the selection number./t2 = precombs(temp2 , numSel);
{
for (temp2 = numSel; temp2 != 0 ; --temp2)
precombo *= temp2;
}
//Calculate the number of combinations.
combos = perms / precombo;
cout << "The number of possible permutations is: " << perms << endl;
cout << "The number of possible combinations is: " << combos << endl;
system("PAUSE");
return 0;
}