Everything seems to be in good order except
Code:
if (party(guests, party))
sameBday += 1
Error stated when compiling:
function designator is not of function type.
Code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int party(int n, int p);
main()
{
int guests, party, prob;
int i;
int sameBday = 0;
srand( time(NULL));
printf("Enter guests: ");
scanf("%d", &guests);
printf("Enter parties: ");
scanf("%d", &party);
if (party(guests, party))
sameBday += 1;
prob = (sameBday / (guests*party)) * 100;
printf("The probability is: %d\n", prob);
}
int party(int n, int p)
{
int i, j;
int bday[];
int temp;
for(j = 1; j <= p; j++)
{
for (i = 1; i <= n; i++)
{
bday[i] = 1 + rand() % 365;
}
for (i = 1; i <= n; i++)
{
if(bday[i] > bday[i + 1])
{
temp = bday[i];
bday[i] = bday[i + 1];
bday[i + 1] = temp;
}
for (i = 1; i <= n; i++)
{
if(bday[i] == bday[i+1])
return 1;
}
}
}
}
Do you know what the meaning of that error is?