.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
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.
.using while loops(matlab) Write a program to display the sum of the series [ 9 +...
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
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.
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 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 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 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 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...
use JOptionPane to display output Can someone please help write a program in Java using loops, not HashMap Test 1 Grades After the class complete the first exam, I saved all of the grades in a text file called test1.txt. Your job is to do some analysis on the grades for me. Input: There will not be any input for this program. This is called a batch program because there will be no user interaction other than to run the program....
Write a program to display the sum of the series 1 + 1/2 + 1/3 + L + 1/n [Use positive integer value n as provided by the user using a scanf statement] in terms of C
Please Help! Write a C++ program to read integers until 9999 is entered (called sentinel – sentinel is used to indicate the end of input and must not to be considered as the valid data for the computation). Perform the following operations for the integers entered by the user. Display the sum of the numbers less than 100 Display the smallest of the positive integers Display the largest of the negative integers Display how many integers are between 100 and...