I just couldn't figure out how to convert it into a while loop. here is the code:

`clc;clear;clear all;n=input('Enter the number of elements in your array:'); % number of array elements`

for i=1:n values(i)=input('Enter the values:') if values(i)<0 values(i)=values(i)*(-1) endendfor k=1:(n-1) d=k+1 Xaverage(k)=(values(d)+values(k))/2endy=1:1:n;plot(values,y)hold onz=1:1:(n-1);plot(Xaverage,z)

## Best Answer