Question
in c please 14.23 Lab 6 Group Sums Name this program groupsum.c. This program accepts two command-line arguments: input filename positive integer group size s
in c please
14.23 Lab 6 Group Sums
Name this program groupsum.c. This program accepts two command-line arguments:
input filename
positive integer group size s
Example: ./a in.txt 3
The input file contains only integers. Write a program that sums integer groups of size s from the input file and outputs these group sums to the terminal. If there are not enough numbers in the file to complete the final group, ignore them and do not print a sum for this partial group.
There will be less than 100 numbers in the input file.
End your input files with an empty newline.
You can get partial credit for this problem if the partial group is printed at the end.
Examples
in.txt
1 2 3 4 6 5 10 20 30 1 1 1 1 2
./a in.txt 3 6 15 60 3
Explanation: 1 + 2 + 3 = 6 4 + 6 + 5 = 15 10 + 20 + 30 = 60 1 + 1 + 1 = 3 1 and 2 are ignored as they are not part of a full group of size 's' (3)
./a in.txt 2 3 7 11 30 31 2 3
Note: You cannot test your code in the ZyBooks' browser window fully as you cannot create input files. in.txt exists.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started