1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
fomenos
1 year ago
7

Question 1

Computers and Technology
1 answer:
Fittoniya [83]1 year ago
8 0

Using the knowledge in computational language in C++ it is possible to write a code that generates and displays 10 random (integer) numbers between 0 and 50.

<h3>Writting the code in C++</h3>

<em>  class SecureRandom : Random</em>

<em>    {</em>

<em>        public static byte[] GetBytes(ulong length)</em>

<em>        {</em>

<em>            RNGCryptoServiceProvider RNG = new RNGCryptoServiceProvider();</em>

<em>            byte[] bytes = new byte[length];</em>

<em>            RNG.GetBytes(bytes);</em>

<em>            RNG.Dispose();</em>

<em>            return bytes;</em>

<em>        }</em>

<em>        public SecureRandom() : base(BitConverter.ToInt32(GetBytes(4), 0))</em>

<em>        {</em>

<em />

<em>        }</em>

<em>        public int GetRandomInt(int min, int max)</em>

<em>        {</em>

<em>            int treashold = max - min;</em>

<em>            if(treashold != Math.Abs(treashold))</em>

<em>            {</em>

<em>                throw new ArithmeticException("The minimum value can't exceed the maximum value!");</em>

<em>            }</em>

<em>            if (treashold == 0)</em>

<em>            {</em>

<em>                throw new ArithmeticException("The minimum value can't be the same as the maximum value!");</em>

<em>            }</em>

<em>            return min + (Next() % treashold);</em>

<em>        }</em>

<em>        public static int GetRandomIntStatic(int min, int max)</em>

<em>        {</em>

<em>            int treashold = max - min;</em>

<em>            if (treashold != Math.Abs(treashold))</em>

<em>            {</em>

<em>                throw new ArithmeticException("The minimum value can't exceed the maximum value!");</em>

<em>            }</em>

<em>            if(treashold == 0)</em>

<em>            {</em>

<em>                throw new ArithmeticException("The minimum value can't be the same as the maximum value!");</em>

<em>            }</em>

<em>            return min + (BitConverter.ToInt32(GetBytes(4), 0) % treashold);</em>

<em>        }</em>

<em>    }</em>

See more about C++ code at brainly.com/question/19705654

#SPJ1

You might be interested in
BRAINLYEST IF CORRECT!!! What is the special feature of the View Side by Side command?
xeze [42]

<u> Allows you to see two parts of the same worksheet side by side</u>

<u>Option: B</u>

<u>Explanation:</u>

The View Side by Side command helps to see the two documents side by side in Word. When using this feature, both the documents open at the same time in different windows side by side.

To view this, click the View tab in Word and then click the View side by side button. Now the document opens in two windows with side by side views. This is used to compare the documents. In case, if we want to disable this view, click the 'View Side by Side' button again so that it comes to the normal view.

6 0
3 years ago
Read 2 more answers
What are your thoughts on copyright?<br><br> (Write 2 or more sentences)
victus00 [196]

Answer:

I look down on copyright. To take someone else's work and disguising it as your own seems like a form of theft.

5 0
3 years ago
Read 2 more answers
When performing actions between your computer and one that is infected with a virus, which of the following offers NO risk of yo
Alexandra [31]

The one already infected, I think ..

6 0
4 years ago
Monero is cryptocurrency that focuses on transparency of ownership. True or false
dangina [55]

Answer:

TRUE

Explanation:

4 0
3 years ago
What is the full form of RAM. ​
grigory [225]

Random Access Memory

7 0
3 years ago
Read 2 more answers
Other questions:
  • What is are example of an engineered item?
    12·1 answer
  • Why is driving a privilege?
    15·2 answers
  • Energy is defined as stored energy
    13·2 answers
  • Select the correct answer
    14·1 answer
  • HELP 11 pointsw to the person who helps me
    11·2 answers
  • A group of interrelated resources acting together according to a plan to accomplish the goals of the records and information man
    5·1 answer
  • What command should be executed to view the configuration of the nic?
    7·1 answer
  • Mark is flying to Atlanta. The flight is completely full with 200 passengers. Mark notices he dropped his ticket while grabbing
    15·1 answer
  • Add me on blizzard none of my friends play ow<br> NADERJABER#2530
    8·1 answer
  • What type of software is needed access the internet
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!