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
MAXImum [283]
3 years ago
5

print out the last even number from an array of integers, if there is no even number, then print out a sentence indicating so.

Computers and Technology
1 answer:
den301095 [7]3 years ago
6 0

Answer:

See the sample algorithm below.

Explanation:

array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 22];

function last_even(arr) {

    for( i = arr.length-1; i >= 0; i--) {

         if (arr[i] % 2 == 0) {

              console.log(arr[i]);

              break;

         }

         else {

              console.log("There is no even number!");

         }

    }

}

last_even(array);

You might be interested in
9. What is the difference between a hand-drawn sketch, a working drawing, and a 3D model?
jarptica [38.1K]
A hand draw sketch is drawing with just a pencil and paper. Also, a working drawing is a drawing on at a job. The 3D sketch is on the computer.

3 0
3 years ago
Write a program that will ask the user for a set of ten numbers. After all ten numbers have been entered, the program will displ
muminat

Answer:

In Python:

nums = []

larg= []

small = []

while True:

   for i in range(10):

       num = int(input(": "))

       nums.append(num)

   print("Smallest: "+str(min(nums))); print("Largest: "+str(max(nums)))

   larg.append(max(nums))

   small.append(min(nums))

   another = int(input("Press 1 to for another sets: "))

   nums.clear()

   if not another == 1:

       break

   

print("Average Large: "+str(sum(larg)/len(larg)))

print("Average Small: "+str(sum(small)/len(small)))

Explanation:

This initializes the list of input numbers

nums = []

This initializes the list of largest number of each input set

larg= []

This initializes the list of smallest number of each input set

small = []

This loop is repeated until, it is exited by the user

while True:

The following iteration is repeated 10 times

   for i in range(10):

Prompt the user for input

       num = int(input(": "))

Add input to list

       nums.append(num)

Check and print the smallest using min; Check and print the largest using max;

   print("Smallest: "+str(min(nums))); print("Largest: "+str(max(nums)))

Append the largest to larg list

   larg.append(max(nums))

Append the smallest to small list

   small.append(min(nums))

Prompt the user to enter another set of inputs

   another = int(input("Press 1 to for another sets: "))

Clear the input list

   nums.clear()

If user inputs anything other than 1, the loop is exited

<em>    if not another == 1:</em>

<em>        break</em>

Calculate and print the average of the set of large numbers using sum and len    

print("Average Large: "+str(sum(larg)/len(larg)))

Calculate and print the average of the set of smallest numbers using sum and len

print("Average Small: "+str(sum(small)/len(small)))

8 0
2 years ago
Care should be taken whenever you post comments or photos to any social media or other websites, because each of these online ac
ohaa [14]

Answer:

True is the correct answer for the above question.

Explanation:

  • The social website is used to connect the people using the internet to communicate. With the help of this, any people can communicate within the world's people.
  • If anyone posts their pictures or comment on this type of website, then they need to care for that post or pictures. it means he needs to make decisions to choose the pictures or comments while posting.
  • It is because when the user posts the wrong comments or pictures, then their popularity is less in front of the other people called society.
  • This concept is also said by the question, hence it is a true statement.
5 0
3 years ago
Write an efficient C++ function that takes any integer value i and returns 2^i ,as a long value. Your function should not multip
Ilya [14]

Answer:

long power(int i)

{

   return pow(2,i);

}

Explanation:

The above written function is in C++.It does not uses loop.It's return type is long.It uses the function pow that is present in the math library of the c++.It takes two arguments return the result as first argument raised to the power of second.

for ex:-

pow(3,2);

It means 3^2 and it will return 9.

4 0
3 years ago
How does coding work on computers?
sleet_krkn [62]
Coding works through programming/programs. Programs have different coding languages, and text files. The code within the file is known as the "source CODE" this code is used in different ways, causing for the possibility of separate binary files that computers can directly run. Hope I helped.

5 0
3 years ago
Other questions:
  • Consider a method defined with the header:
    13·1 answer
  • What would be one advantage and one risk of using an electric car?
    14·2 answers
  • What kind of value should an employee possess when employees are expected to be responsible and fair?
    7·1 answer
  • What is key for evaluating internal controls such as human resources, logistics, information technology, risk, legal, marketing
    11·1 answer
  • Write a C++ program that computes an approximation of pi (the mathematical constant used in many trigonometric and calculus appl
    15·1 answer
  • If your internet were to go out, what steps would you take to troubleshoot to restore your service?
    15·1 answer
  • Int a = 1; int b = 0; int c = -1; if ((b + 1) == a) { b++; c += b; } if (c == a) { a--; b = 4; }
    7·1 answer
  • What does NOT match with Agile Manifesto?
    9·1 answer
  • Website managers use____ every day.
    10·2 answers
  • When you insert a new slide in a presentation, where is it placed in relation to the existing slides?.
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!