1. Write a computer code ( in MATLAB ), for BOTH part c and d, that contans the
ID: 3781868 • Letter: 1
Question
1. Write a computer code (in MATLAB), for BOTH part c and d, that contans the following assignment statements exactly as shown. Analyze the results.
c. What values would the following assignment state- ments produce? integer i, j; real c, f, x, half x 10/3 i integer (x 1/2) half 1/2 j integer (half) c (5/9) (f 32) f 9/5c 32 output x, i, half, j, c, f d. Discuss what is wrong with the following pseudocode Segment: real area, circum, radius radius 1 area (22/7)(radius) circum 4- 2(3.1416)radius output area, circumExplanation / Answer
% matlab code part C
x = 10/3;
i = int64(x+1/2);
half = 1/2;
j = int64(half);
f = 0;
c = (5/9)*(f-32);
f = (9/5)*c+32;
fprintf("x: %f i: %d half: %f j: %d c: %f f: %f ",x,i,half,j,c,f);
%{
output:
x: 3.333333
i: 4
half: 0.500000
j: 1
c: -17.777778
f: 0.000000
%}
% matlab code part D
radius = 1;
area = (22/7)*radius*radius;
circum = 2*3.1416*radius;
fprintf("Area: %f ",area);
fprintf("Circumference: %f ",circum);
%{
output:
Area: 3.142857
Circumference: 6.283200
%}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.