# Thread: Deal or No Deal Proogram

1. ## 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]); }`

2. Get into the game!

You need a function to decide what the value the banker will offer for the player's case. You need a player's response to that offer. You need a way of opening a case that the player has asked to be opened.

The idea department is a toughie, because it's not a part of C, and it's impossible to tell just what is holding you back from starting.

Maybe play a game or two, with a pad and pen, or watch a few re-runs of the show on the net.

There are similar threads to this on the forum, so maybe reading some of them will help give you idea's. make your program your own work, however.