You are on page 1of 1

clc;

clear;

n=input('How many numbers do you want to store? ' );

p=input('What is the size of your desired array? ' );

array=(1:p);

disp('Okay! Now enter the numbers: ')

for i=1:n
array(i)=input('' );
end

sum=0;

for i=1:n
sum = sum + array(i);
end

disp('The sum of the entered numbers has been calculated!')

q=input('At what position (should be less than or equal to size of the array) of
the array do you want to store the sum? ' );

array(q)=sum;

m=input('Number at which position of the array do you want to know? ' );

disp(['Number at enquired position of the array = ', num2str(array(m))])

You might also like