Answer to Question #265562 in C++ for Usama

Question #265562

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.



1
Expert's answer
2021-11-22T07:08:47-0500

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





Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS