© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•8mo ago•
22 replies
Chroma

Making program run again

How can I make my program run over and over again even if it's done doing it's job? I.e this is my program and the last execution it does, is the if statement. After I have to close the terminal and run it again. I thought with while loop maybe it can work but i didnt get that work

Console.WriteLine("Please type a random word:\t");
String input = Console.ReadLine();
String[] words = {"apple", "car", "basket", "tv"};
Random random = new Random();
int index = random.Next(words.Length);
String randomWord = words[index];
Console.WriteLine(randomWord);
if (input == randomWord) {
    Console.WriteLine("You guessed the word! It was\t" + randomWord);
} else {
    Console.WriteLine("Sorry. The word was:\t" + randomWord);
}
Console.WriteLine("Please type a random word:\t");
String input = Console.ReadLine();
String[] words = {"apple", "car", "basket", "tv"};
Random random = new Random();
int index = random.Next(words.Length);
String randomWord = words[index];
Console.WriteLine(randomWord);
if (input == randomWord) {
    Console.WriteLine("You guessed the word! It was\t" + randomWord);
} else {
    Console.WriteLine("Sorry. The word was:\t" + randomWord);
}
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

How can I make my program run a bool again? weird bug
C#CC# / help
8mo ago
✅ need some help making a program
C#CC# / help
2y ago
✅ My program can’t be run.
C#CC# / help
16mo ago
Student - Can't run program frontend
C#CC# / help
3y ago