lizzie5121 lizzie5121
  • 09-07-2020
  • Computers and Technology
contestada

Type two statements that use rand() to print 2 random integers between (and including) 100 and 149. End with a newline.

Ex: 101 133

Respuesta :

frknkrtrn
frknkrtrn frknkrtrn
  • 11-07-2020

Answer:

#include <iostream>

using namespace std;

int main()

{

   cout<< rand() % 50 + 100 <<endl;

   cout<<rand() % 50 + 100 <<endl;

   

   return 0;

}

Explanation:

The rand() gives you a random number. If you use rand() % 50, it will give you a random number between 0 and 49. Since we are required to have the numbers between 100 and 149, add 100 to this expression. This way, you will have a random number between 100 and 149. Type this expression two times and use "endl" to end with a new line.

Answer Link

Otras preguntas

what are the aplication of heating effect of electric current?
Respiration is a vital function of the body.' Justify the statement
what type of reaction will occur when lead nitrate is mixed with the potassium iodide solution?
Three vertices of a rectangle are (–3, 4), (5, 4), and (5, –2). What are the coordinates of the fourth vertex of the rectangle?          A.
A common source of 'potential difference' or 'voltage' is a cell or battery. Explain
How is the amount of urine produced regulated?
Name the organ where ammonia converted in to urea.
during the election of 1936 declaring their party a millionaires union Franklin Roosevelt focused mainly on defeating the
what wilhappen if fertillization is doone when no egg is released,
give one equation that could generate the ordered pair (2,8)