Generate Random Number in C# Between 1 to 10 – Programming, Pseudocode Example, C# Programming Example
C# Console General

Generate Random Number in C# Between 1 to 10

The Random class of .NET class library provides functionality to generate random numbers in C#

The Random class has three public methods – Next, NextBytes, and NextDouble. The Next method returns a random number, NextBytes returns an array of bytes filled with random numbers, and NextDouble.

 

The following code returns a random number between 1 and 10

 

 

1 Comment

  • PLease help me here

    Have you ever looked up a phone number and repeated it to yourself over and over so you
    can dial it correctly? Seconds later you have forgotten it. This draws on your short-term
    memory. There are many games for improving memory. One of them is the “In Order”
    game. In this game, a random number with at least three digits is generated and printed
    on the screen for a player to remember before being hidden. Each player takes a turn
    attempting to repeat the number. For example, a random number 658 with three digits is
    displayed for three seconds (check the table below for the time limits for different difficulty
    levels). Then a ten digit input bar is shown in numerical order to allow the player to input
    the remembered number. A player attempts to repeat the previously displayed numbers by
    clicking the digits in the same order. Each player has up to three attempts before a new
    number is generated for the other player. In total there are five rounds for each player.
    Table 1. Time limits and Scores for Difficult Levels
    Difficult level
    (number length)
    3, 4, or 5 digits 6, 7, or 8 digits 9 or 10 digits
    Time limit (seconds) 3 4 5
    Score 3 4 5
    In this assignment you are required to write a program that implements this game. Your
    program should initially allow players to create their usernames and choose a difficulty
    level. The usernames can only contain letters and numbers. If they do not choose a
    difficulty level your program should start at the lowest level with three digits by default. A
    time limit should then be set according to Table 1 above. When the time limit has been
    reached the number is hidden and the ten digits are displayed in numerical order (see
    Figure 1 for a sample interface). The first player then needs to click on digits in the same
    sequence to gain a score (see Table 1 for scores). If the player fails within three attempts
    your program should generate a new number at the same difficulty level for the other
    player. It should only move on to next level if someone wins.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.