1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Tema [17]
3 years ago
12

Write programs with loops that compute:

Computers and Technology
1 answer:
Katarina [22]3 years ago
6 0

Answer:

The programs are written in MATLAB.

(a)

sum = 0;

for i = 2:100  %This for loop starts from 2 and ends at 100

   sum = sum + i;  %This line sums each values of the loop

end

disp(sum); %This command displays the sum at command window

(b)

sum = 0;

for i = 2:100

   sum = sum + i^2;  %This line sums the squares of each values in the loop

end

disp(sum);

(c)

sum = 0;

a = input('Please enter a: ');

b = input('Please enter b: ');

for i = a:b

   if mod(i,2) == 1  %This command checks whether the value in the loop is odd or not

       sum = sum + i;  %This command sums each odd value in the loop

   end

end

(d)

seq = input('Please enter a few numbers with square brackets [] around them: ');

small = seq(1);  %Initialize small

large = seq(1);  % Initialize large

for i = 1:length(seq)  %Iterate over the sequence

   if seq(i) < small

       small = seq(i);  %Decide if the value in the loop is smallest

   elseif seq(i) > large

       large = seq(i);  %Decide if the value in the loop is largest

   end

end

fprintf('The smallest of the inputs is %g,\nThe largest of the inputs is %g.\n',small,large);

You might be interested in
When a formula contains the address of a cell, it is called a(n)
Shalnov [3]
When a formula contains the address of a cell, it is called a c<span>ell reference.

hope this helps!</span>
8 0
4 years ago
Which of the following best describes a server?
Lady_Fox [76]

Answer:

number 4

Explanation:

7 0
3 years ago
Read 2 more answers
You have local administrative rights to your computer running windows 7. you cannot find some of the operating system files on y
ElenaW [278]
<span>a. uncheck ���hide protected operating system files��� in folder options</span>
6 0
3 years ago
Which component of an email gives the recipient an idea of the email’s purpose and urgency?
Delvig [45]

Answer:

subject line

Explanation:

it is a brief description of what the email subject is.

4 0
3 years ago
A bug collector collects bugs every day for seven days. Write a program in Python that finds the highest number of bugs collecte
Mama L [17]

Answer:

mylist = [ ]

for i in range(7):

   mylist.append (int(input("Enter the number of bugs for each day ")))

print(mylist)

print("The highest number of bugs is ")

print(max((mylist)))

Explanation:

  1. Create and Initialize an empty (mylist)
  2. Using the .append method, we request and add the bugs for each day into the list
  3. print out the list
  4. Use the max function to find the highest number of bugs in the list and print it out

5 0
3 years ago
Other questions:
  • Create the Following Menu in a loop so the menu will continually show until the user chooses to exit.AddMultiplyExitAdd a value
    10·1 answer
  • The requester of sensitive information should not receive access just because of his or her clearance, position, or rank. The re
    15·1 answer
  • Customizing ads to people who had earlier visited the site is
    14·1 answer
  • Interruption attacks are also called ___ attacks:
    8·1 answer
  • Trong ửod muốn trình bày dạng cột càn thực hiện lệnh nào
    13·1 answer
  • What is a Forloop and what is it used for?
    7·2 answers
  • An entrepreneur identifies and fills the gap between what the society needs and what is available is called​
    5·1 answer
  • Question 19
    9·2 answers
  • Extend the class linkedListType by adding the following operations: Write a function that returns the info of the kth element of
    12·1 answer
  • True or false: if you are adding your own css sheet, make sure your css file comes before the bootstrap css file.
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!