Question

.using while loops(matlab) Write a program to display the sum of the series [ 9 +...

.using while loops(matlab)

Write a program to display the sum of the series [ 9 + 99 + 999 + 9999 ...]

Test Data :

Input the number or terms :5

Expected Output

:

9 99 999 9999 99999

The sum of the series = 111105

0 0
Add a comment Improve this question Transcribed image text
Answer #1

MatLab program

clear all
clc
% n is no. of terms
n=input('Input the number of terms: ');
i=1;
a=0;
while i<=n
    a=a+0.9*10^(i);
    x(i)=a;
    i=i+1;
end
fprintf('\n Series is :\n');
disp(x);
fprintf('\n Sum of series = %d',sum(x));

Screenshot

Save the above program and execute it.

Result

I hope this will help you.

Add a comment
Know the answer?
Add Answer to:
.using while loops(matlab) Write a program to display the sum of the series [ 9 +...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT