Hello everyone! I am new to this forum (and C programming) but I hope that I will be able to master C help anyone out with problems in the coming months. But I am having trouble with my own program for an assignment.
I am asked to simulate a user entered number of birthday parties and user entered number of guests at each party. I am supposed to have a function with the prototype int party(int n) that will simulate one party at a time with n guests. I have to assign each guest with a random birthday and have the program check to see if two of the guests have the same birthday. If one party has two guests with the same birthday, the function returns 1. If all the birthdays at one party are different, the function returns 0.
Then main() counts the number of 1's, divides it by the number of parties and prints out a percentage.
I got a little bit into the program and got stuck.
#include <stdlib.h>
#include <time.h>
int party(int g, int p);
main()
{
int guests;
float parties, samebday;
srand(time(NULL));
party(guests, parties);
system("PAUSE");
return 0;
}
int party(int g, int p)
{
int guests, count;
float parties;
printf("Enter the number of parties: ");
scanf("%f", &parties);
printf("Enter the number of guests: ");
scanf("%d", &guests);
for (count = 1; count <= guests; count++)
{
//testing with printf to see if loop works
printf("%d \n", 1 + rand() % 365);
}
}
Like I said before, I am a complete noob with C programming and any help would be appreciated. Thank you!