probability calculator with factorial equation

0 votes

I have to make a code that calculates the probability of winning the lottery given the amount of numbers there are to choose from and how many you must choose. I must use the factorial equation (n!)/(k!*(n-k)!) in the code. The code itself works fine, but the equation will not compile.

//This program calculates the probability of winning the lottery
#include <iostream>

using namespace std;

double factorial(int n, int k);

int main()
{
    //variables
    int n;
    int k;
    char pa;
    int chance;
    double prob;

    //loop
    do
    {

        cout << "How many numbers (1-12) are there to pick from?\n" << endl;
        cin >> n;

        if(n>12 || n<1)
        {
            cout << "Invalid entry.\nHow many numbers (1-12) are there to pick from?\n";
            cin >> n;
        }

        cout << "How many numbers must you pick to play?\n";
        cin >> k;

        if(k>n || k<1)
        {
Mar 14, 2022 in SalesForce by surbhi
• 3,820 points

edited Mar 4 21 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP