Quiz 10

I have uploaded the source files for my to programs of my Quiz 10:

For this program I used something that isn’t very usual, the % operator. This is used to return the modulus of a division, this means the number at the left of the operator is divided by the number at the right, and the result is the residue of the first division of them. This way you can know if a number is evenly divisible by another. Whenever a number is evenly divisible it module returns 0.

So I check the module and if it is cero we add the number to the total that is afterward printed in the console.

The next program first verifies that the lengths of the lists provided are equal, if they are not there’s no calculation to compute so we only print out the error message and return a -1. If they are we take the element of the same index of both lists, calculate the product of them and then add it to the total, which is later on returned by the function.

This is my of my

 

CC BY 4.0 Quiz 10 by Manuel Lepe is licensed under a Creative Commons Attribution 4.0 International License.

Comments are closed.