Hi guys! I have to make a small programs which calculates the number of possible combinations. Suppose there are 6 guests and 4 chairs then possible combinations are 360. My program is working fine for these two numbers but for other numbers it is not showing correct result.
1 2 3 4 5 6 7 8 9 10 11 12
int main()
{
int a,b;
int c=1;
cout<<"Guests and Chairs: ";
cin>>a>>b;
for (int i=a; i>=(b-1); i--)
c *= i;
cout<<c<<endl;
system ("pause");
return 0;
}
Will you guys please help me correct this?
Thanks in advance. God bless u all.
I think i should type teh question as it is:
A dinner party for 6 guests but i have 4 chairs. In how many ways can six guests can arrang themselves? Any of 6 guests can sit in the first chair. then any of five can sit on the second chair. Any of the remaining four can sit on the third chair and any of the remining three can sit on the last chair (Last two will have to stand). So number of possible arrangements are 6*5*4*3=360.
now i hve to write a program for any number of guests and chairs given guests>chairs.