Question: This is the third time I am trying to ask the same question to get a correct answer so I hope you can help me

This is the third time I am trying to ask the same question to get a correct answer so I hope you can help me out here, I need this following code to work like the example picture:

#include

using namespace std;

unsigned long int read_input(string question) {

unsigned long int user_input;

while (true) {

cout

cin >> user_input;

if (user_input > 0) {

return user_input;

} else if(user_input

cout

}

}

}

unsigned long int factorial(unsigned long int i) {

unsigned long int k = 1;

while (i > 0) {

k *= i;

i -= 1;

}

return k;

}

unsigned long int calculate_probability(unsigned long int n, unsigned long int p) {

if(p == 0) return 1;

return factorial(n) / (factorial(p) * factorial(n - p));

}

int main() {

unsigned long int balls_tot = read_input("Enter the total number of lottery balls: ");

unsigned long int ball_count = read_input("Enter the number of drawn balls: ");

if (ball_count > balls_tot) {

cout

} else {

cout

}

return 0;

}

This is the third time I am trying to ask the same

What should I do?

Enter the total number of lottery balls: 20 Enter the number of drawn balls: 4 The probability of guessing all 4 balls correctly is 1/4845 Enter the total number of lottery balls: 3 Enter the number of drawn balls: 4 The number of balls must be a positive number

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!