Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

As a senior member of a well-known company, you have been asked to analyze, check and evaluate the output of many codes. The following

 

As a senior member of a well-known company, you have been asked to analyze, check and evaluate the output of many codes. The following two codes form a small part of your task: Code 1: v=13 1 5]; i=1; for r 1: length(v) = j=v(r); i=i+1; end ifi 3 end i=i+2; m=i+j; . Code 2: n-input( 'Number of terms?"); % n The last digit of your ID (1" digit from the right) +5 S-0; for k 1:1:n s-s+1/(k2): end: g-sqrt(6+s); disp(sqrt(6s)) A. Draw up a table of the values of i, j, k and m to show how they change while the script executes for both codes. B. Work out by hand the value of each variable in both codes after each iteration. C. Check your answers by running the script. D. Now rewrite the script of code 2 using vectors and array operations (without using "for" or "while" loop). Then, comment on your answer. Parts D, E and F are based on code 2 only:

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial Management for Public Health and Not for Profit Organizations

Authors: Steven A. Finkler, Thad Calabrese

4th edition

133060411, 132805669, 9780133060416, 978-0132805667

More Books

Students also viewed these Programming questions

Question

What are the principal methods used to schedule media?

Answered: 1 week ago

Question

What are the potential benefits of electronic invoicing?

Answered: 1 week ago