What does this pseudocode do? a. Describe it in general (use one sentence only)
ID: 645218 • Letter: W
Question
What does this pseudocode do?
a. Describe it in general (use one sentence only)
b. Describe it step-by-step for each line (just write next to it line by line)
c. Convert this pseudocode into a working MATLAB program
1 Declare A As Integer
2 Declare B As Integer
3 Declare N As Integer
4 Set A=0
5 For ( B=1; B <= N; B++ )
6 Set A = A + (2 * B - 1)
7 Set B = B + 1
8 End For
9 Write A
_______________
Here is what I have so far. Can someone help me with the rest of it? Not sure if its correct.
N=input('Enter an Integer For N:');
%Input Integer
%Int(Integer)
A=0;
for B=1:N
A=A+(2*B-1);
B=B+1;
end
disp(A)
Explanation / Answer
A = int32(1);
B = int32(1);
N = int32(1);
N = input('Enter an Integer For N:');
A = 0;
for B=1:N
A = A + (2 * B - 1);
B = B + 1;
end
disp(A)
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.