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, 05.07.2019 20:30
Asign featuring a red circle and red line crossing over an image
Answers: 1
question
Law, 14.07.2019 13:10
Sonja is writing an essay about becoming a preschool teacher. complete it by correctly filling in the missing information. out of all the career choices in the career cluster, i'd like to be a preschool teacher. i love working with children, and i think it would be a rewarding career in which i could create lessons and the students prepare socially and academically for kindergarten. in order to become a preschool teacher, i'll need to complete high school and it'll also be important to work on my creativity, interpersonal, and organizational skills. i know that when i work hard to complete the academic requirements, i'll be prepared for the career path that interests me most.
Answers: 2
question
Law, 15.07.2019 23:10
You are a member of the parole board and you hear joe donovan's case. do you grant parole or not? support your answer with at least three supporting facts from the video.
Answers: 3
question
Law, 16.07.2019 17:10
Which of the following ideological types favor government activism in the economic realm? a. liberals and populists b. populists and libertarians c. conservatives and liberals d. populists and conservatives
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
English, 05.11.2020 18:10
question
Mathematics, 05.11.2020 18:10
question
English, 05.11.2020 18:10
question
Chemistry, 05.11.2020 18:10
Questions on the website: 13722363