Write a program that will ask the user to input a single number N. If the number
ID: 3806972 • Letter: W
Question
Write a program that will ask the user to input a single number N. If the number is a nonzero, a one hundred element row vector named SEQ will be filled with the values 0.01*N, 0.02*N,... 0.99*N, N. Note that this must work for both positive and negative values of N. After filling the vector, the program should ask if this is correct, or does the user want to enter a new value for N, in which case it should refill SEQ with the corrected values. This should continue until the user enters a zero, at which point the program terminates.
Explanation / Answer
function SEQ = createVector(N)
SEQ = linspace(0.01*N, N, 100); %0.01*N:0.01*N:100
end
N = input("input a single number : ")
while N != 0
SEQ = createVector(N)
disp(SEQ)
isCorrect = input("Is this correct or you want to enter new value of N? (0/1): ")
if (isCorrect == 1)
break
end
N = input("input a single number : ")
end
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.