#include void main (void) { int people, i; const int days_in_leap_year = 366; double probability_of_no_shared_birthdays, probability_of_shared_birthday; cout << "Enter number of people at party (zero or -ve to stop): "; cin >> people; while (people > 0) { if (people > days_in_leap_year) { cout << "It is certain that two people will share a birthday." << endl; } else { probability_of_no_shared_birthdays = 1.0; i = 1; while (i < people) { probability_of_no_shared_birthdays *= (double(days_in_leap_year - i) / days_in_leap_year); i++; } probability_of_shared_birthday = 1.0 - probability_of_no_shared_birthdays; if (probability_of_shared_birthday > 0.999999) { cout << "It is almost certain that two people will share a birthday." << endl; } else { cout << "There is a " << probability_of_shared_birthday * 100 << "% chance that two people will share a birthday." << endl; } } cout << "Enter number of people at party (zero or -ve to stop): "; cin >> people; } // we don't need to pause here (even if using the system in the lab) // because there's no reason to keep the screen around. }