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
sweet-ann [11.9K]
3 years ago
11

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

Computers and Technology
1 answer:
bogdanovich [222]3 years ago
8 0

C Code:

#include <stdio.h>      // Enables use of printf

#include <stdlib.h>   // Enables use of rand()

#include <time.h>     // Enables use of time()

int main(void)

{

srand(time(0));  

int random1 = rand()% 50 + 100;

int random2 = rand()% 50 + 100;  

printf("%d\n", random1);

printf("%d\n", random2);

  return 0;

}

Output:

115

141

Explanation:

Each time program executes, srand() function generates new random numbers.

rand()%50 + 100 makes sure that number is 2 digit and within the range of 100 to 150.

Then we print the two random numbers where %d represents that we want to print an integer and \n represents new line  

You might be interested in
Write a program that defines an interface having the following methods: addition, subtraction, multiplication, and division. Cre
Tatiana [17]

Hello, you haven't provided the programing language in which you need the code, I'll explain how to do it using Python, and you can follow the same logic to make a program in the programing language that you need.

Answer:

1. # -*- coding: utf-8 -*-

2. #Python  

3. class Calculator:

4.     def add(self):

5.         print(a + b)

6.     def sub(self):

7.         print(a - b)

8.     def mul(self):

9.         print(a * b)

10.     def div(self):

11.         print(a / b)

12.  

13. obj = Calculator()

14. choice = 1

15. while choice != 0:

16.     a = int(input("\nEnter first number: "))

17.     b = int(input("Enter first number: "))

18.      

19.     print("\n0. EXIT")

20.     print("1. DIVISION")

21.     print("2. ADDITION")

22.     print("3. SUBTRACTION")

23.     print("4. MULTIPLICATION")

24.      

25.     choice = int(input("\nEnter your choice: "))

26.     if choice == 1:

27.         obj.div()

28.     elif choice == 2:

29.         obj.add()

30.     elif choice == 3:

31.         obj.sub()

32.     elif choice == 4:

33.         obj.mul()

34.     else:

35.         break

Explanation:

  • From lines 1 to 12 we define the object with four methods, addition, subtraction, multiplication, and division. Each method contains the operation between two variables inside a print function
  • On line 13 we instantiate our class
  • On line 14 we declare the variable choice that is going to store the operation that the user wants to perform
  • On line 15 we declare a while loop, this is going to keep running the program until the user wants to exit
  • From line 16 to 18 we ask the user to enter two numbers
  • From line 19 to 24 we print the possible operation, assigning a number for each operation, this indicates to the user what number to press for what operation
  • On line 25 we ask the user for the operation
  • From lines 26 to 35 we check the user input an accordingly we call the corresponding method to performs the operation
7 0
3 years ago
The factorial of n is equal to ______.
alexdok [17]

Answer:

n! = n*(n-1)*(n-2)*(n-3)* ... *2*1

Explanation:

The factorial operator is simply a mathematical expression of the product of a stated integer and all integers below that number down to 1.  Consider these following examples:

4! = 4 * 3 * 2 * 1

4! = 12 * 2 * 1

4! = 24

6! = 6 * 5 * 4 * 3 * 2 * 1

6! = 30 * 4 * 3 * 2 * 1

6! = 120 * 3 * 2 * 1

6! = 360 * 2 * 1

6! = 720

So, the factorial of n would follow the same as such:

n! = n * (n-1) * (n-2) * ... * 2 * 1

Cheers.

5 0
2 years ago
What is one way interpreted programming languages differ from compiled programming languages? (3 points)
Allisa [31]

Answer:b

Explanation:

3 0
3 years ago
Match the tool to its description.
topjm [15]

Answer:

Reveal formating- A

Clear formatting-B

Apply formatting of the surrounding text-D

Format painter-C

Explanation:

7 0
2 years ago
Read 2 more answers
(TCO 1) You want to find the IP address of an interface. How can you quickly do this?
defon

Answer:

Ping the interface using the cmd or terminal

Explanation:

5 0
2 years ago
Other questions:
  • Para saan po yung points dito?
    15·1 answer
  • When looking to ensure your website is easily accessible by mobile users, what should you focus on doing first
    8·1 answer
  • Define critical thinking, and list the mental activities involved in critical thinking.
    8·2 answers
  • ​Lara is the chief editor of "Laughter and Life," an online magazine. Lara has assigned Jenny the task of redesigning the magazi
    5·1 answer
  • Which technology has the potential to be misused to make atomic bombs? A. computer technology B. nuclear technology C. medical t
    14·1 answer
  • Modify class Time2 of fig 8.5, (which is split into four pictures) to include a tick method that increments the time stored in a
    8·1 answer
  • Isa wants to find out if his co-worker Alexis is available for an event on Wednesday, February 10th. Which calendar
    12·1 answer
  • If Anyone can help me out that'll be great
    11·1 answer
  • I came here for a answer so why did i get a pep talk
    7·2 answers
  • An information system can enhance core competencies by
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!