long seats;
long no_of_guests;
    long fact=1;
    cout<<"Enter the number of seats nn";
    cout<<"nnEnter the number of guestsnn";
    for(int i=0;i<seats;i++)
    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 


Enter the number of guests


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
:) :)

Edited 3 Years Ago by pyTony: fixed formatting

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.

Edited 5 Years Ago by Red Goose: n/a

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

This question has already been answered. Start a new discussion instead.