I'm a freshman engineering student, and attempting to write a simple game in the C programming language. The basic concept is that of an adventure story; you are given several options to choose from and each option leads you down a different path. I want to create a type of loop so that if a person is to choose an incorrect option, they are able to repeat the previous prompt. I have copied and pasted an excerpt from my code below. How would I proceed to create this type of loop? If you need clarification on what I am trying to do, I will attempt to provide it.
printf("You enter into a circular room. There are seven doors on the wall.");
printf(" Which door would you like to enter?\n");
printf("\n");
printf("1: Door 1\n");
printf("2: Door 2\n");
printf("3: Door 3\n");
printf("4: Door 4\n");
printf("5: Door 5\n");
printf("6: Door 6\n");
printf("7: Door 7\n");
printf("\n");
printf("Which door do you choose?\n");
printf("\n");
scanf("%lf", &CHOICE3);
if (CHOICE3 == 1)
{
printf("\n");
printf("You open Door 1. There is nothing behind it. You leave and go back");
printf(" to the room with the doors.\n");
}
if (CHOICE3 == 2)
{
printf("\n");
printf("You open Door 2. There is a shirtless man behind it. He turns around");
printf(" and says 'Hello.' You say hi back, and then tell him that");
printf(" you're leaving now. He says 'Okay.' You leave. How awkward.");
printf(" You go back to the room with the doors.\n");
}
if (CHOICE3 == 3)
{
printf("\n");
printf("You open Door 3. Behind it stands a sphinx, and behind him stands");
printf(" an archway. He will not let you pass unless you correctly answer");
printf(" his riddle. The riddle reads:\n");
printf("\n");
}
And thus you get what I'm trying to do. How would I code it so that if the person chose Door 2, they would end up back in the room with the doors?