# Deal or No Deal Proogram

• 03-28-2010
shel5210
Deal or No Deal Proogram
Our teacher gave us a little sample code, and told us to write a deal or no deal program in C. I am stuck as to where to start. Here is the code. Thanks in advance!!!

Code:

```#define SIZE 10 int main (void){ int prizes[SIZE] = {1,5,10,25,50,100,250,500,1000,5000}; int cases[SIZE]= {0}; const int arraylength = SIZE; //constant used for size of arrays srand(time(NULL)); /*seeds random number generator, not a function you create*/ fillcases(cases, prizes, arraylength);```
Code:

```void fillcases (int cases[], int prizes[], int arraylength){ int randnum = 0; int i = 0; int sentinel=0; for(i=0;i<SIZE;i++){ sentinel = 0; while (sentinel==0) { randnum = (rand()%SIZE); /* 0-9 inclusive */ if(cases[randnum]==0){ cases[randnum] = prizes[i]; sentinel=1; } } } }```
And then this was also given:

1. unopenedcases – this function has no output variables and takes in the cases array and arraylength variables. The function uses a loop to index through the cases array. Within the loop, an if statement is used to check if the indexed case has not been emptied yet, if the case is not empty, the case number is displayed to the screen.

2. lookatprizes – this function has no output variables and takes in the cases array, the prizes array, and the arraylength variable. The function uses a nested loop structure and this statement to test if the prize value is still within the cases array.
Code:

`if(prizes[i]==cases[j]) { printf("\$%d ", prizes[i]); }`
• 03-28-2010