Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Part 2. [10 marks] Given a file where each line is a single (32-bit) integer, read in the lines of the file one at a

image text in transcribed
Part 2. [10 marks] Given a file where each line is a single (32-bit) integer, read in the lines of the file one at a time; output n sums computed the fyllowing way: sum i is the sum modulo 240223 of every vth line starting from the 0 th until you've summed (i+1) lines, where v>0 is the value of the last line. That is, first you output the 0th line. Then you output the sum of the 0 th and vth line. Then you output the sum of the 0 th, vth, and 2vth line, etc. All of this is modulo 240223 , and you treat the list circularly using modular arithmetic. If the file is empty, output 0 . For example, if the input is 10203040504v=4,n=6 then the output is because we output 6(=n) sums, and the sum on line i is the sum of the lines obtained from the 0 th, vth,2vth,,(iv)th lines. For more examples, see the tests in the tests/ directory that have the form lab2-p2-X-in.txt for the input, and the matching lab2-p2-x-out txt for the expected output

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Describe the reasons against imposing tax on income?

Answered: 1 week ago

Question

1. Identify six different types of history.

Answered: 1 week ago

Question

2. Define the grand narrative.

Answered: 1 week ago

Question

4. Describe the role of narratives in constructing history.

Answered: 1 week ago