Write a programming C++ that calculates the number of possible arrangements for any number of guests and any number of chairs. (Assume there will never be fewer guests than chairs). A simple for loop should do it. for example the possible arrangement of six guests in four chairs is 360.
Source code
#include <iostream>
using namespace std;
int main()
{
int no_guests;
int no_chairs;
cout<<"\nEnter number of guests: ";
cin>>no_guests;
cout<<"\nEnter number of chairs: ";
cin>>no_chairs;
int n=no_guests- no_chairs;
int no_arrangmnt=1;
for(int i=no_guests;i>n;i--){
no_arrangmnt*=i;
}
cout<<"\nNumber of possible arrangement = "<<no_arrangmnt;
return 0;
}
Output
Comments
Leave a comment