Combinations

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <iostream>
using namespace std;
int main()
{
 
 int n,m,v=1,c1,c2,p=1,k;
 cout<<"n = ";
 cin>>n;
 cout<<"m = ";
 cin>>m;
k=3; 
for(int br=1;br<=k;br=br+1)
p=p*br;
for(int br=n;br>=n-k+1;br=br-1)
v=v*br;
c1=v/p;
k=2; 
for(int br=1;br<=k;br=br+1)
p=p*br;
for(int br=m;br>=m-k+1;br=br-1)
v=v*br;
c2=v/p;
cout<<"c="<<c1*c2<<endl;
    
 
 return 0;
}

If we have n multiple choice questions and m close test questions. In how many ways we can create an exam with 3 multiple choice questions and 2 close test questions. Test values n=5; m=3, the result should be c=30 but when I compile it is c=300, I can't find my mistake, please if anyone may help! Thanks in advance!
Last edited on
Topic archived. No new replies allowed.