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
On an XBOX 360, what does it mean if you get 4 red rings on your console?
Hitman42 [59]

Answer:

C. This happened to me.

Explanation:

4 0
3 years ago
Some 3d printers work by controlling the exact locations where a liquid
kow [346]
Were a liquid what? id doesn't make any sense.
6 0
3 years ago
Read the code below.
Rasek [7]

Answer:

theres an error on line one used python idle

Explanation:

8 0
3 years ago
R15. Suppose there are three routers between a source host and a destination host. Ignoring fragmentation, an IP datagram sent f
maria [59]

Answer:

The answers are: an IP datagram, and 3 forwading tables.

Explanation:

An IP datagram sent from a source host to a destination host will travel through 8 interfaces. 3 forwarding tables will be indexed to move the datagram from source to destination.

8 0
2 years ago
What are the diffrent types of contract
igomit [66]
<span>Fixed Price Contracts, Cost Reimbursable Contracts, and <span>Time and Material Contracts are the three basic types. Not to mention </span></span>Sale contracts, Employment contracts, business contracts, and leases.
4 0
3 years ago
Other questions:
  • Assume you're running a query on your orders in the past year. You want to see how many orders were placed after May. What type
    5·1 answer
  • Ideally an entity identifier is composed of _____ attribute(s).
    11·1 answer
  • On most desktop computers, most of the USB ports are on the back of the computer case. Generally, you'll want to connect your mo
    13·1 answer
  • What language must be used to display a bare-minimum webpage?
    8·2 answers
  • Portable Document Format (PDF) is a file format that provides an electronic image of a document and can be viewed, printed, and
    12·2 answers
  • Science Help
    11·1 answer
  • What is a file path?
    7·1 answer
  • How do you open an application on the macOS?
    11·2 answers
  • What do earthquakes and tsunamis have in common?
    13·1 answer
  • How to square a number in java.
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!