MATLAB: Write a loop program to find greatest of N number entered by user.Use input as 0 to stop entering number.

homeworkloopMATLABuser input

I have to enter as many numbers as wished then when I enter 0 as input the program give the greatest number entered.

Best Answer

count = 0 ;
a = 1;
prompt = 'Enter the number:' ;
while a ~= 0
count = count+1 ;
a = input(prompt) ;
b(count) = a ;
end
max_b = max(b) ;
fprintf ('Greatest number is %d\n',max_b)
Related Question