Answer:
x = 1;
sum = 1;
while sum <=10000
x = x+2;
sum = sum + x;
end
a = sprintf('last number = %d\\the sum would be = %d',x,sum);
disp(a)
Step-by-step explanation:
- Start with 1 as the initial sum .
- Inside the while loop, apply the condition that will stop the loop as soon as sum exceeds the value 10,000 .
- Finally add the next odd whole number and print the result.