Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7398817
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T03:55:07+00:00 2026-05-29T03:55:07+00:00

I am making a random number guessing game which the computer thinks of a

  • 0

I am making a random number guessing game which the computer thinks of a number between 1-100. It then asks you what it is and tells you if you are right or wrong. However, whenever I debug, it says that it is higher or lower than the actual random number for some reason. Plus, it says two of those statements at once. Also, I’m not sure how to say how many guesses the person has taken. Here is my unsuccessful code.

static void Main(string[] args) 
{
    Random random = new Random();

    int returnValue = random.Next(1, 100);
    int Guess = 0;

    Console.WriteLine("I am thinking of a number between 1-100.  Can you guess what it is?");

    while (Guess != returnValue)
    {
        Guess = Convert.ToInt32(Console.Read());

        while (Guess < returnValue)
        {
            Console.WriteLine("No, the number I am thinking of is higher than " + Guess + " .  Can you guess what it is?");
            Console.ReadLine();

        }
        while (Guess > returnValue)
        {
            Console.WriteLine("No, the number I am thinking of is lower than " + Guess + " .  Can you guess what it is");
            Console.ReadLine();
        }
    }
    while (Guess == returnValue)
    {
        Console.WriteLine("Well done! The answer was " + returnValue);
        Console.ReadLine();
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T03:55:07+00:00Added an answer on May 29, 2026 at 3:55 am

    You’re using a lot of unneeded iteration. The while statement takes a Boolean condition just like an IF statement.

        static void Main(string[] args)
        
        {
        
        Random random = new Random();
        
        int returnValue = random.Next(1, 100);
        
                int Guess = 0;
        
                Console.WriteLine("I am thinking of a number between 1-100.  Can you guess what it is?");
        
                while (Guess != returnValue)
                {
                    Guess = Convert.ToInt32(Console.ReadLine());
        
                    if (Guess < returnValue)
                    {
                        Console.WriteLine("No, the number I am thinking of is higher than " + Guess + ". Can you guess what it is?");
                    }
                    else if (Guess > returnValue)
                    {
                        Console.WriteLine("No, the number I am thinking of is lower than " + Guess + ". Can you guess what it is?");
                    }
    
                }
    
                Console.WriteLine("Well done! The answer was " + returnValue);
                Console.ReadLine();
                
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am making a password generator that generates a random number, then I have
a)In this case does the random number generator uses the system's clock (making the
So I am making this Guess the number game in c++ that looks like
can anybody help me in making a method to generate random number without repetition
How would I go about creating a random number generator which has a bias
Making an adobe flex ui in which data that is calculated must use proprietary
I am making a page that accepts post data from any number of pages
Possible Duplicate: Random number generator not working the way I had planned (C#) I
I am making an app that generates random numbers for android (you can find
I'm making Sudoku game. There are two classes: difficulty and Screen class. When the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.