The Intermediate code generated below is for a given statement M-p*q+r/s is as follows: T1 = id5 T2 = id: / T1 T3 = id3+T2 T4 = id;*T3 M = T4 Write the output for code optimization and Code generation.
Q: cost1 = 15 cost2 = 20 def sumCart(): totalCost = cost1 + cost2 print (totalCost)…
A: The modified python code (with explanation and sample output) to meet the given requirements is…
Q: Write a program in C to print a diamond using *. Ask the use to input the height of the pyramid.…
A: Please find the answer below :
Q: s shown in the picture.
A: Define header file <bits/stdc++.h> Define main function Define int variable x with value 6 Use…
Q: Computer Science QuestionIn input you are provided with two words of the same length. Each word…
A: I have answered this question in step 2.
Q: new dataframe containing only that weight class.) Use examples to justify that your dataframes have…
A: Step 1: import pandas as pd weight_class_list= ['47', '52' ,'57' ,'63', '72' ,'84' ,'84+', '59'…
Q: Requirements: Plan each program by writing pseudocode. Add more comments as needed in each program…
A: logic: read n,minimum,maximum pass n,minimum and maxmum to function define…
Q: QUESTION: Write a C++ program that will generate and display a magic square. A magic square is a…
A: C++ code #include<iostream>#include<iomanip>using namespace std; const int MAX_SIZE =…
Q: Please written by computer source Python asignment For this assignment you are to implement a…
A: The Python code is given below with output screenshot
Q: In c programming Assume that you have a function named add_three_nums() which will take three…
A:
Q: Lab Functions 2 Topics covered: C++ Program Development Practice, Loops, Functions and Arrays Lab…
A: Given , the answer is given below
Q: make a c++ code that takes an input array, and outputs the sum of each consecutive number. Here is…
A: Required: pls make a c++ code that takes an input array, and outputs the sum of each consecutive…
Q: The quadratic formula is used to solve a very specific type of equation, called a quadratic…
A: PROGRAM EXPLANATION: - The Disc.py contains the discriminant function having three parameters for…
Q: Topics: while, basic I/O, conditional structure, list, for loop Problem Statement: In this lab, you…
A: condition: Equality Checks if two If c1 = a1 - ib1 and c2 = a2 - ib2 are two complex numbers,…
Q: ASSIGNMENT: Write a program to use the capability of Recursion to calculate factorials. For example,…
A: in java import java.util.Scanner;public class Factorial { public static void main(String[]…
Q: Where is the void function for circumference
A: We need to write the void function for circumference. In Python, all functions return value whether…
Q: I need help on this?
A: The objective of the question is to create a program that analyzes the words played by professional…
Q: Code the function multiplier(). //**** **** ******* k**** //The multiplier function takes 2 integer…
A: C++ program for multiplication using multiplier function. User has to enter two integer to be…
Q: Intro to Python Programming:
A: Required:
Q: The Worksheet named Grades contains a place for students to record the grades they have received in…
A: Sub showValue() Dim arr(9) For i = 0 To 8 Step 1 arr(i) = Range("B" & (i + 2)) Next…
Q: Python question Application: Python Fragment Formulation (Q1 – Q4) In this group of questions you…
A: As per Bartleby rules we can answer only first 3 subparts. I request you to post question 4…
Trending now
This is a popular solution!
Step by step
Solved in 2 steps
- (Statistical) In many statistical analysis programs, data values considerably outside the range of the majority of values are simply dropped from consideration. Using this information, write a C++ program that accepts up to 10 floating-point values from a user and determines and displays the average and standard deviation of the input values. All values more than four standard deviations away from the computed average are to be displayed and dropped from any further calculation, and a new average and standard deviation should be computed and displayed.(Data processing) Your professor has asked you to write a C++ program that determines grades at the end of the semester. For each student, identified by an integer number between 1 and 60, four exam grades must be kept, and two final grade averages must be computed. The first grade average is simply the average of all four grades. The second grade average is computed by weighting the four grades as follows: The first grade gets a weight of 0.2, the second grade gets a weight of 0.3, the third grade gets a weight of 0.3, and the fourth grade gets a weight of 0.2. That is, the final grade is computed as follows: 0.2grade1+0.3grade2+0.3grade3+0.2grade4 Using this information, construct a 60-by-7 two-dimensional array, in which the first column is used for the student number, the next four columns for the grades, and the last two columns for the computed final grades. The program’s output should be a display of the data in the completed array. For testing purposes, the professor has provided the following data:(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?
- (Numerical) a. The following is an extremely useful programming algorithm for rounding a real number to n decimal places: Step 1: Multiply the number by 10n Step 2: Add 0.5 Step 3: Delete the fractional part of the result Step 4: Divide by 10n For example, using this algorithm to round the number 78.374625 to three decimal places yields: Step1:78.374625103=78374.625 Step2:78374.625+0.5=78375.125 Step3:Retainingtheintegerpart=78375Step4:78375dividedby103=78.375 Using this algorithm, write a C++ function that accepts a user-entered value and returns the result rounded to two decimal places. b. Enter, compile, and run the program written for Exercise 11a.Mark the following statements as true or false: a. To use a predefined function in a program, you need to know only the name of the function and how to use it. (1) b. A value-returning function returns only one value. (2, 3) c. Parameters allow you to use different values each time the function is called. (2, 7, 9) d. When a return statement executes in a user-defined function, the function immediately exits. (3, 4) e. A value-returning function returns only integer values. (4) f. A variable name cannot be passed to a value parameter. (3, 6) g. If a C++ function does not use parameters, parentheses around the empty parameter list are still required. (2, 3, 6) h. In C + + , the names of the corresponding formal and actual parameters must be the same. (3, 4, 6) i. A function that changes the value of a reference parameter also changes the value of the actual parameter. (7) j. Whenever the value of a reference parameter changes, the value of the actual parameter changes. (7) k. In C++, function definitions can be nested; that is, the definition of one function can be enclosed in the body of another function. (9) l. Using global variables in a program is a better programming style than using local variables, because extra variables can be avoided. (10) m. In a program, global constants are as dangerous as global variables. (10) n. The memory for a static variable remains allocated between function calls. (11)(Numerical) Heron’s formula for the area, A, of a triangle with sides of length a, b, and c is A=s(sa)(sb)(sc) where s=(a+b+c)2 Write, test, and execute a function that accepts the values of a, b, and c as parameters from a calling function, and then calculates the values of sand[s(sa)(sb)(sc)]. If this quantity is positive, the function calculates A. If the quantity is negative, a, b, and c do not form a triangle, and the function should set A=1. The value of A should be returned by the function.
- (Civil eng.) Write a C++ program to calculate and display the maximum bending moment, M, of a beam that’s supported on both ends (see Figure 3.8). The formula is M=XW(LX)/L, where X is the distance from the end of the beam that a weight, W, is placed, and L is the beam’s length. You program should produce this display: The maximum bending moment is xxxx.xxxx The xxxx.xxxx denotes placing the calculated value in a field wide enough for four places to the right and left of the decimal point. For your program, assign the values1.2,1.3,and11.2toX,W,andL.(Conversion) a. Write a C++ program to convert meters to feet. The program should request the starting meter value, the number of conversions to be made, and the increment between metric values. The display should have appropriate headings and list the meters and the corresponding feet value. If the number of iterations is greater than 10, have your program substitute a default increment of 10. Use the relationship that 1 meter = 3.281 feet. b. Run the program written in Exercise 6a on a computer. Verify that your program begins at the correct starting meter value and contains the exact number of conversions specified in your input data. c. Modify the program written in Exercise 6a to request the starting meter value, the ending meter value, and the increment. Instead of the condition checking for a fixed count, the condition checks for the ending meter value. If the number of iterations is greater than 20, have your program substitute a default increment of (ending value - starting value) / 19.(Computation) Among other applications, Pascal’s triangle (see Figure 7.22) provides a means of determining the number of possible combinations of n things taken r at a time. For example, the number of possible combinations of five people (n = 5) taken two at a time (r=2)is10. Each row of the triangle begins and ends with 1. Every other element in a row is the sum of the element directly above it with the element to the left of the one above it. That is, element[n][r]=element[n1][r]+element[n1][r1] Using this information, write and test a C++ program to create the first 11 rows of a twodimensional array representing Pascal’s triangle. For any given value of n less than 11 and r less than or equal to n, the program should display the correct element. Use your program to determine in how many ways a committee of 8 can be selected from a group of 10 people
- 15. Write a program to implement and test the algorithm that you designed for Exercise 15 of Chapter 1. (You may assume that the value of . In your program, declare a named constant PI to store this value.)When you borrow money to buy a house, a car, or for some other purpose, you repay the loan by making periodic payments over a certain period of time. Of course, the lending company will charge interest on the loan. Every periodic payment consists of the interest on the loan and the payment toward the principal amount. To be specific, suppose that you borrow $1,000 at an interest rate of 7.2% per year and the payments are monthly. Suppose that your monthly payment is $25. Now, the interest is 7.2% per year and the payments are monthly, so the interest rate per month is 7.2/12 = 0.6%. The first months interest on $1,000 is 1000 0.006 = 6. Because the payment is $25 and the interest for the first month is $6, the payment toward the principal amount is 25 6 = 19. This means after making the first payment, the loan amount is 1,000 19 = 981. For the second payment, the interest is calculated on $981. So the interest for the second month is 981 0.006 = 5.886, that is, approximately $5.89. This implies that the payment toward the principal is 25 5.89 = 19.11 and the remaining balance after the second payment is 981 19.11 = 961.89. This process is repeated until the loan is paid. Write a program that accepts as input the loan amount, the interest rate per year, and the monthly payment. (Enter the interest rate as a percentage. For example, if the interest rate is 7.2% per year, then enter 7.2.) The program then outputs the number of months it would take to repay the loan. (Note that if the monthly payment is less than the first months interest, then after each payment, the loan amount will increase. In this case, the program must warn the borrower that the monthly payment is too low, and with this monthly payment, the loan amount could not be repaid.)(Electrical eng.) a. An engineer has constructed a two-dimensional array of real numbers with three rows and five columns. This array currently contains test voltages of an amplifier. Write a C++ program that interactively inputs 15 array values, and then determines the total number of voltages in these ranges: less than 60, greater than or equal to 60 and less than 70, greater than or equal to 70 and less than 80, greater than or equal to 80 and less than 90, and greater than or equal to 90. b. Entering 15 voltages each time the program written for Exercise 7a runs is cumbersome. What method could be used for initializing the array during the testing phase? c. How might the program you wrote for Exercise 7a be modified to include the case of no voltage being present? That is, what voltage could be used to indicate an invalid voltage, and how would your program have to be modified to exclude counting such a voltage?