in Education by
I have to make this an infinite loop and also make it go back to the start when a wrong character is an input. What to do? This is my code so far: #include #include int main () { // Prompt user for input last choice contender char c; printf("Last choice: "); c = getchar(); // If last choice is R, loser should play S if (c == 'R'|| c == 'r') { printf("Your next move: S"); } // Else if last choice is P, loser should play R else if (c == 'P' || c == 'p') { printf("Your next move: R"); } // Else if last choice is S, loser should play P else if (c == 'S' || c == 's') { printf("Your next move: P"); } // TO DO: If another character start over else if (c != 'S'|| c != 's' || c != 'P' || c != 'p' || c != 'R'|| c != 'r') } // TODO: make an infinite loop / start over JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
I there are multiple ways of doing this, i recommend a while loop. Add a while(){ } around all the code you want to reiterate, inside the while() parameters you can have a boolean like this boolean won = false, while(!won) and add the won = true when a player has won, or when you dont want the player to continue your game! But i also recommend reading about the while loop, google while loop in google

Related questions

+1 vote
    What is an infinite loop in C-Programming?...
asked Nov 9, 2020 by JackTerrance
0 votes
    I have an endless loop problem in Simpy simulation. My scenario is: After finishing triage, a patient wait ... ): admin_decision_prob = random.uniform(0, 1) if admin_decision_prob...
asked Apr 7, 2022 in Education by JackTerrance
0 votes
    When new SaveModelAction() is called, the corresponding Effect gets stuck in an infinite loop. This the ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 26, 2022 in Education by JackTerrance
0 votes
    When new SaveModelAction() is called, the corresponding Effect gets stuck in an infinite loop. This the ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 24, 2022 in Education by JackTerrance
0 votes
    I was reading the great article about binding and unbinding events (because I am a js beginner using jQuery ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 9, 2022 in Education by JackTerrance
0 votes
    I was reading the great article about binding and unbinding events (because I am a js beginner using jQuery ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 8, 2022 in Education by JackTerrance
0 votes
    I was reading the great article about binding and unbinding events (because I am a js beginner using jQuery ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 8, 2022 in Education by JackTerrance
0 votes
    I was reading the great article about binding and unbinding events (because I am a js beginner using jQuery ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 6, 2022 in Education by JackTerrance
0 votes
    I was reading the great article about binding and unbinding events (because I am a js beginner using jQuery ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 5, 2022 in Education by JackTerrance
0 votes
    What is an infinite loop?...
asked Jan 18, 2021 in Technology by JackTerrance
0 votes
    I need to react in a main process to random events happening in a child process. I have implemented ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 27, 2022 in Education by JackTerrance
0 votes
    Smriti wants to give output of a program in infinite loop which statement will you suggest to her to use? In qbasic Select the correct answer from above options...
asked Dec 21, 2021 in Education by JackTerrance
0 votes
    Write two points difference between Null loop and infinite loop Select the correct answer from above options...
asked Dec 17, 2021 in Education by JackTerrance
0 votes
    infinite for loop PYTHON Select the correct answer from above options...
asked Nov 30, 2021 in Education by JackTerrance
0 votes
    An infinite ladder is constructed with 1 Ω and 2 Ω resistor shown below. The current I flowing through the circuit ... GATE EC Exam, Network Theory MCQ (Multiple Choice Questions)...
asked Oct 12, 2021 in Education by JackTerrance
...