long seats;
long no_of_guests;
    long fact=1;
    cout<<"Enter the number of seats nn";
    cin>>seats;
    cout<<"nnEnter the number of guestsnn";
        cin>>no_of_guests;
    for(int i=0;i<seats;i++)
    {
        fact*=no_of_guests;
        no_of_guests--;
    }
    cout<<"the possible combinations : "<<fact<<"nn";

this code has run successfully but there is a something that I couldn't get

first this program will run this way:

Enter the number of seats 

4

Enter the number of guests

6


the possible combinations : 360


press any key to continue..........

if I entered for example in seats 300
and in number of guests 400
then this is the output

the possible combinations : 0

my question is why the output is zero and not the actual answer

thank you
:) :)

Most likely you're exceeding the limitation of the variable, so at some point, it's counting over to 0, and then multiplies from 0 there onward.

Not much can be done about that, except perhaps storing the number inside a container or something of the like. You're not going to find a variable type that can hold a number as big as you're trying to make.

I just wanted to make sure of what I concluded and your answer helped me .....
Thank You very much
:) :)

Just wanted to point out that your answer is wrong. There are only 15 combinations.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.