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

Other questions on the subject: Law

image
Law, 08.07.2019 23:40, rostecorralmart
Which of the follow statements about drinking alcohol and driving is true
Answers: 1
image
Law, 16.07.2019 18:10, cicilee49
Who is the petitioner and who is the respondent?
Answers: 1
image
Law, 16.07.2019 23:20, irenecupcake4348
The occupational safety and health administration promulgated a rule requiring warehouse employees to wear hardhats when in the vicinity of an operating forklift. the purpose of the hardhats is to protect employees from danger of falling objects. this rule is
Answers: 2
image
Law, 17.07.2019 02:20, alexandraparava
What positions can the president appoint?
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 in other subjects:

Konu
English, 21.05.2020 00:01
Konu
History, 21.05.2020 00:01