This is what I have now, I am still working on the final part of the loop:
Code:
#include <stdio.h>
#include <stdlib.h>
int game()
{
int door[3]={0,0,0};
int choice, i, newdoor, originaldoor, openeddoor, randomnumber;
if (originaldoor=1);
{
openeddoor = rand() % 3+1;
}
printf("Door %d does not have the prize\n", openeddoor);
printf("Would you like to switch your door? 1 for yes 2 for no.\n");
scanf("%d" , &choice);
while ((choice<0) || (3<choice))
{
printf("You entered an invalid number\n");
break;
}
if
(choice=1)
{
{
newdoor=choice;
}
if
(choice=0)
newdoor=originaldoor;
}
if (newdoor=1);
{
printf("You have won the prize!\n");
}
if (newdoor=0);
{
printf("You lose!\n");
}
}
int main(void)
{
int door[3]={0, 0, 0};
int x, prize, randomnumber, originaldoor, choice, newdoor, y;
prize=1;
while (1)
{
srand (time(NULL));
originaldoor = rand() % 3 + 1;
door[randomnumber] = 1;
printf("Which door do you pick 1, 2, or 3? 0 to exit.\n");
scanf("%d", &originaldoor);
game(originaldoor);
if ((0>=originaldoor) || (originaldoor>3))
{
break;
}
}
return(0);
}