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
- (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_forwardComplete the function that calculates the sum of the first n+1 terms of the geometric series a, ar, ar² ar³, arª ….. arn Note that the series begins with a and the last term is ar", in total there are n+1 terms. 1: # complete the function given the #variables a,r,n and return the value as series_sum. def sum geometric_series(a,r,n): # YOUR CODE HERE return series_sum print (sum_geometric_series (4.0, 5, 10))arrow_forwardThe correct statements are: For L = 0, L* = {e} For L = {e}, L* = {e} OL+ = LL* L* = LL+arrow_forward
- The Harris-Benedict equation estimates the number of calories your body needs to maintainyour weight if you do no exercise. This is called your basal metabolic rate, or BMR.The formula for the calories needed for a woman to maintain her weight isBMR = 655 + (4.3 x weight in pounds) + (4.7 x height in inches) -(4.7 x age in years)The formula for the calories needed for a man to maintain his weight isBMR = 66 + (6.3 x weight in pounds) + (12.9 x height in inches) -(6.8 x age in years)A typical chocolate bar will contain around 230 calories. Write a program that allows the userto input his or her weight in pounds, height in inches, age in years, and the character M formale and F for female. The program should then output the number of chocolate bars thatshould be consumed to maintain one's weight for the appropriate sex of the specified weight,height, and age.arrow_forwardAlert dont submit AI generated answer.arrow_forwardc# Write program that asks to enter an x numbers and sum the even numbers and odd numbers separately then print the sum?arrow_forward
- What does Python function procedure do? def procedure( n ): while n > 0: print (n,) n = n - 1 Select one: a. Counts from 10 down to 0 and displays each number b. Counts from n down to 1 and displays each number c. Calculates the sum of n numbers greater than 0 d. Calculates the mean of narrow_forwarddo in python programming languagearrow_forwardComputer Science This is an introductory exercise to the manipulation of random variables with Python as a language for scientific computing and numerical computation. You have: f(x) = Ae-0.1x)° 4 x*, 0arrow_forwardComplete the following Codearrow_forwardQ2/ Complete the time expressions with for or since. half an hour a long time October last Tuesday a couple of weeks 2001 ten o'clock I was 14 three monthsarrow_forwardBased on the Python codes below, which of the following is/are true: Code A: Code B: Code C: Select one or more: def factorial(x): if x == 0: return 1 else: num - 5 print("The factorial of", num, "is", factorial (num)) return (x factorial(x-1)) Result: "The factorial of 5 is 120" def factorial (x): if x == 0: else: return 1 num - 5 printf("The factorial of", num, "is", factorial(num)) return (x factorial (x-1)) Result: did not execute def factorial(x): if x < 0: a Code A has syntax error. b. Code Chas semantic error. Oc Code B has syntax error. d. Code B has semantic error. else: e Code Chas syntax error. Of Code A has semantic error. return 1 num= 5 print("The factorial of", num, "is", factorial (num)) return (x factorial (x-1)) Result: "The factorial of 5 is 0"arrow_forwardarrow_back_iosSEE MORE QUESTIONSarrow_forward_ios
- Programming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage LearningC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
- Microsoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT