Write a script file using the proper iteration statement to read in a number x and calculate its exponential using Taylor series for the first 10 terms.

Matlab codes quick questions

Read each question carefully. Questions 1-3 are 10 points each. Question 4 is 20 points. Total 50 points.

For Questions 1-2, submit your answers in a single MS Word or PDF file. For Question 3-4, submit the two written script files along with the MS Word or PDF file. Three files should be submitted.

Do NOT submit screenshots.

Draw the flow diagrams for for loop and while loop, separately. (10 points)

What does a jump statement do to an iteration statement? What is the difference between a break statement and a continue statement? (10 points)

The Taylor series for the exponential function ex is given below. Write a script file using the proper iteration statement to read in a number x and calculate its exponential using Taylor series for the first 10 terms. (10 points)

1 + βˆ‘ (π‘₯^𝑛

𝑛! )

∞

𝑛=1

Write a script program using a proper loop statement to perform the following tasks: (20 points)

(1) Per-determine a random integer (rand_int) between [0-9] by the program (hint: use randi() ).

(2) Let the user guess a number (number) entered from the keyboard to be compared with the random integer (rand_int).

(3) If the value of number matches the value of rand_int, the program should display a message β€˜Bingo! The guessing is stopped by the program.’ and terminate.

(4) If the two values of number and rand_int are not matched, the program should ask whether the user wants to keep guessing by displaying β€˜Wrong guessing… try again?’.

(5) To continue guessing, a character β€˜Y’ or β€˜y’ should be entered from the keyboard; to stop guessing, a character β€˜N’ or β€˜n’ should be entered, and display β€˜The guessing is stopped by the user.’.

Write a script file using the proper iteration statement to read in a number x and calculate its exponential using Taylor series for the first 10 terms.
Scroll to top