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
  • USING FOR AND WHILE LOOPS-MATLAB) 6. Write a program to display the number in reverse order....

    USING FOR AND WHILE LOOPS-MATLAB) 6. Write a program to display the number in reverse order. Test Data : Input a number: 12345 Expected Output : The number in reverse order is : 54321

  • Use Matlab to write a program to display the cube of the number up to a...

    Use Matlab to write a program to display the cube of the number up to a given integer. (USE BOTH FOR & WHILE LOOPS PLEASE) Test Data: Input number of terms : 5 Expected Output : Number is : 1 and cube of the 1 is :1 Number is : 2 and cube of the 2 is :8 Number is : 3 and cube of the 3 is :27 Number is : 4 and cube of the 4 is :64...

  • Matlab: Write a program that calculates and stores in a vector the results of the sum...

    Matlab: Write a program that calculates and stores in a vector the results of the sum 9 + 99 + 999 + 9999 + .... for any number of components.

  • USE MATLAB: USE FOR AND WHILE LOOPS Write a program to check whether a number is...

    USE MATLAB: USE FOR AND WHILE LOOPS Write a program to check whether a number is a palindrome or not. Palindromes are numbers that read same backward and forward. Test Data : Input a number: 121 Expected Output : 121 is a palindrome number.

  • Solve Question using While loops-MATLAB Write a program that generates a random number and asks the...

    Solve Question using While loops-MATLAB Write a program that generates a random number and asks the user to guess what the number is. If the user's guess is higher than the random number, the program should display "Too high, try again." If the user's guess is lower than the random number, the program should display "Too low, try again." The program should use a loop that repeats until the user correctly guesses the random number.

  • Topics c ++ Loops While Statement Description Write a program that will display a desired message...

    Topics c ++ Loops While Statement Description Write a program that will display a desired message the desired number of times. The program will ask the user to supply the message to be displayed. It will also ask the user to supply the number of times the message is to be displayed. It will then display that message the required number of times. Requirements Do this assignment using a While statement.    Testing For submitting, use the data in the...

  • In MATLAB Write a script to determine the number of terms required for the sum of...

    In MATLAB Write a script to determine the number of terms required for the sum of the series (5k? – 2k) not to exceed 100,000 using the while loop. Display the number of terms and the calculated sum using fprint () command as follow: The number of terms is 38 and its sum is 93613

  • Lab 5-2 Nested Loops 2. Summation Of Numbers (using Nested While Loops) Part A: The program...

    Lab 5-2 Nested Loops 2. Summation Of Numbers (using Nested While Loops) Part A: The program will calculate and display the total of all numbers up to a specific number (entered by the user). Only positive numbers are allowed. Part B: User-controlled loop Part A Input Validation loop Part A: Summation loop Examples: When 5 is entered the program will calculate the total as 1+2+...+5 and display 15. When 2 is enterered the program will calculate the total as 1+2...

  • Python 3.6 "While Loops" Write a program that adds up a series of numbers entered by...

    Python 3.6 "While Loops" Write a program that adds up a series of numbers entered by the user. The user should enter each number at the command prompt. The user will indicate that he or she is finished entering the number by entering the number 0.   Example This program will sum a series of numbers. Enter the next number (enter 0 when finished) > 5 Enter the next number (enter 0 when finished) > 2 Enter the next number (enter...

  • Write a program Using loops to display the following patterns – (i) ********** (ii) ******************** (iii)...

    Write a program Using loops to display the following patterns – (i) ********** (ii) ******************** (iii) * ** *** **** ***** ****** ******* ******** ********* ********** (iv) * ** *** **** ***** ****** ******* ******** ********* ********** *********** ************ ************* ************** *************** **************** ***************** ****************** ******************* ******************** (v) ********** ********* ******** ******* ****** ***** **** *** ** * (vi) ******************** ******************* ****************** ***************** **************** *************** ************** ************* ************ *********** ********** ********* ******** ******* ****** ***** **** *** ** * Your...

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