subject
Law, 26.02.2020 06:31 natalie2sheffield

Two files named numbers1.txt and numbers2.txt both have an unknown number of lines, each line consisting of a single positive integer. Write some code that reads a line from one file and then a line from the other file. The two integers are multiplied together and their product is added to a variable called scalar_product which should be initialized to zero.

Your code should stop when it detects end of file in either file that it is reading.

For example, if the sequence of integers in one file was "9 7 5 18 13 2 22 16" and "4 7 8 2" in the other file, your code would compute:

4*9 + 7*7 + 8*5 + 2*18

and thus store 161 into scalar_product.

ansver
Answers: 2

Another question on Law

question
Law, 03.07.2019 16:10
How would you answer this question. how could you build your practice as an educator for equity, diversity, and inclusion to avoid the oppression of marginalized populations of students?
Answers: 2
question
Law, 08.07.2019 05:10
What is the difference between university and college?
Answers: 2
question
Law, 12.07.2019 04:20
My town doesn't allow solar panels, but i know they are a great source of renewable energy and can save you money. how can i make my town allow solar panels?
Answers: 2
question
Law, 13.07.2019 16:10
If the light is green as you approach an intersection, you should: a. cover your brakes b. expect it to change soon c. speed up to enter the intersection
Answers: 1
You know the right answer?
Two files named numbers1.txt and numbers2.txt both have an unknown number of lines, each line consis...
Questions
question
Chemistry, 21.08.2019 20:20
question
Chemistry, 21.08.2019 20:20
Questions on the website: 13722362