Write a program that prompts the user for the value x, reads the value, calculates sin(x), and prints the value. The val

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

Write a program that prompts the user for the value x, reads the value, calculates sin(x), and prints the value. The val

Post by answerhappygod »

Write A Program That Prompts The User For The Value X Reads The Value Calculates Sin X And Prints The Value The Val 1
Write A Program That Prompts The User For The Value X Reads The Value Calculates Sin X And Prints The Value The Val 1 (120.76 KiB) Viewed 40 times
Write a program that prompts the user for the value x, reads the value, calculates sin(x), and prints the value. The value x is in radians and is assumed to be between plus and minus two pi. Expect the user to enter a correct value for x. Use the Taylor series: sin(x) = x - x?/3! + x°/5! - x?/7! + x°/9! The function uses a loop. The loop counts up for terms numbered 1, 3, 5, 7, 9, and so on. Each iteration corresponds to a term x/n! which is added or subtracted to the running sum. Each iteration calculates its term by multiplying the term from the previous iteration by x/ (n(n-1)), where n is the number of the new term. Do not calculate n! nor x" from scratch for each iteration. Just multiply the previous term by xạ/ (n(n-1)). Then add the resulting new term to the sum. Add up 11 terms of the series (so the largest n will be 21). Do this in a counting loop. Enter x: 1.0 Sin (x) : 0.84147096 Another run: Enter x: -2.13 Sin(x) : -0.8476778 QtSpim may print out more digits than shown above. Test the program several times with different values, including negative. For some of your runs use x = 0.0, x = 1.0, x = 1.570793, x = -1.0 and others of your choice. Set MIPS settings to the following: OFF Bare Machine OFF Enable Delayed Loads OFF Enable Delayed Branches ON Load Exception Handler OFF Enable Mapped IO ON Accept Pseudo Instructions As always, include a register use table and comment nearly every line of the program. Make sure that the fields of the assembly language statements are nicely aligned in columns. Do not use any tab characters in your source file.
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply