Concept explainers
Define the range of the random numbers generated by the following expressions:
Want to see the full answer?
Check out a sample textbook solutionChapter 4 Solutions
Computer Science: A Structured Programming Approach Using C, Third Edition
- Using python Suppose rand is a random floating-point number from 0.0 up to 1.0. a. Give an expression to obtain a random floating-point number from 14.5 up to 24.5. b. Give the range of random numbers for the expression 73.9rand + 21.2. Answer format (min-max)arrow_forwardtrace the following code and give the output. for (int num=0; num< 10; num++) if (num%2 == 0) cout << num << " ";arrow_forwardGiven four numbers from user input, decrement the first number by 3 and increment the second number by 2, Then do the magic calculations as follows: get the sum of the first two numbers, deduct the second number from the third and get the product of the third and forth number, then sum up the results of the three magic calculations. Sample run 1: Enter four numbers separated by spaces: 4 2 3 8 Output: Result of Magic calculations = 28 Sample run 2: Enter three numbers separated by spaces: 1 2 3 -6 Output: Result of Magic calculations = -17 a) Write a Pseudocode to solve the above problem Create a flowchart for the above pseudocodearrow_forward
- Determine the value of each of the following expressions. (For decimal numbers, round your answer to two decimal places.) (1) abs(-18) fabs(20.5) fabs(-87.2) pow(4, 2.0) pow(8.4, 3.5) sqrt(7.84) sqrt (196.0) sqrt (38.44)* pow(2.4, 2) / fabs(-3.2) floor(27.37) ceil(19.2) floor(12.45) + ceil(6.7) floor (-8.9) + ceil (3.45) floor(9.6) / ceil(3.7) pow(-4.0, 6.0) pow(10, -2.0) pow(9.2, 1.0 / 2)arrow_forward(Numerical) Using the srand() and rand() C++ library functions, fill an array of 1000 floating-point numbers with random numbers that have been scaled to the range 1 to 100. Then determine and display the number of random numbers having values between 1 and 50 and the number having values greater than 50. What do you expect the output counts to be?arrow_forwardPlease answer part b using Mathematica. Display code and output pleasearrow_forward
- Determined if the following given below are regular expressions or NOT.arrow_forwardIn the expression, int n = 12 + rand() % 57;arrow_forwardUsing Heron's formula, you can calculate the area of a triangle if you know the lengths of all three sides. Given the length of each side of a triangle as input, calculate the area of the triangle using Heron's formula as follows: s = half of the triangle's perimeter area = the square root of s(s-a)(s-b)(s-c), where a, b, and c are each sides of the triangle. Use the Math.sqrt() method for calculating the square root. Output the floating-point value of the area with three digits after the decimal point, which can be achieved as follows:System.out.printf("The area of the triangle is %.3f\n", yourValue);arrow_forward
- Homework: Use Matlab Matrix: Generate a random real number in the range from 0 to 1. Generate a random real number in the range from 0 to 50. Generate a random real number in the range from 10 to 20. Generate a random Integer in the range from 1 to 10.arrow_forwardGiven a and b are int variables and c is a double variable. The initial value for a, b, and c are 8, 4, and 2.5. Show the working steps and result for the following expression:(i) a + b++ - carrow_forwardthe code is in python for reference Find the error: daily_sales = [0.0, 0,0, 0.0, 0.0, 0.0, 0.0, 0.0] days_of_week = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'] for i in range(7): daily_sales[i] = float(input('Enter the sales for ' \ + days_of_week[i] + ': '))arrow_forward
- Programming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage LearningC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr