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
2. Input a decimal number and test if it is not equal to 16.5.
lubasha [3.4K]

Answer:

2:

decNum = float(input("Decimal number: "))

if decNum != 16.5:

   print("Does not equal")

elif decNum == 16.5:

   print("Equal")

else:

   pass

3:

if x > 57:

   x += 4

   print(x)

4:

numOne = int(input("Enter number: "))

numTwo = int(input("Enter number: "))

if numOne < 100 and numTwo < 100:

   yes = numOne + numTwo

   print(yes // 2)

else:

   pass

Explanation:

Please give me brainliest.

6 0
2 years ago
What is a back door?
V125BC [204]

Answer:

A backdoor is a typically covert method of bypassing normal authentication or encryption in a computer, product, embedded device, or its embodiment. Backdoors are most often used for securing remote access to a computer, or obtaining access to plaintext in cryptographic systems.

Explanation:

3 0
3 years ago
Read 2 more answers
CP/IP over Ethernet supports basic frames with a total size of up to 1518 bytes (including both the message payload and headers)
Ne4ueva [31]

Answer:

I think you just add all the Bytes together

6 0
3 years ago
What computer part do you need to make you’re pc run faster?
Alisiya [41]
There are multiple things that effect the speed of your computer such as the processer, RAM, and what is on the computer itself. The first question would be to figure out what might be slowing down your computer and the reason for needing the increase in speed. This will tell you what part you need and the steps to take.
3 0
3 years ago
What does the ‘random’ part of Random Access Memory refer to?
Tems11 [23]

Answer:

it means it store a few in information randomly because it process different information at the same time

7 0
3 years ago
Other questions:
  • kelly wants to buy a new operating system for a laptop. under which category will it be in online store?
    5·1 answer
  • Electricity was seen as a mysterious force and began to creat a stir when people called​
    13·1 answer
  • __________ is when a person feels compelled to acquire and abuse a drug despite the harm it causes him or her personally, and de
    14·1 answer
  • In a case where electrical current leakage from the circuit occurs, the GFCI would do the following:
    10·1 answer
  • “Union-compatible” means that the ____.
    13·1 answer
  • 4. Explain the term prejudice. What is an example of prejudice as it relates to parenting?
    11·1 answer
  • Microsoft ____________________ is a complex, full-featured firewall that includes stateful packet filtering as well as proxy ser
    10·1 answer
  • The owner of a candle shop has asked for your help. The shop sells three types of candles as shown below:
    14·1 answer
  • What can be changed when a style is modified?
    5·2 answers
  • Any song recommendations, pls dont say 6ix9ine or lil pump
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!