Can anyone help me with this one? I have the following code and produces an output, but the Probability stays at 1 regardless of how many students I input....Any ideas?
#include <iostream>
#include <fstream>
#include <cmath>
using namespace std;
void main()
{
int numStudents, DayOfBirth, cnt;
double Probability, Power;
cout << "Enter Number of Students in The Room: " << endl;
cin >> numStudents;
cout << endl;
Power = (numStudents * (numStudents - 1)) / 2;
Probability = (1 - pow((364)/(365) , Power));
cnt = 0;
while (cnt < numStudents)
{
DayOfBirth = rand() % 365;
cout << "Student Date of Birth is: " << DayOfBirth << endl;
cnt++;
}
cout << "Number of Students is: " << cnt << endl;
cout << "Probability of sharing DOB: " << Probability << endl;
}