Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Use C++ programming in below two problems. Problem G1 This program will read integers from a file and find results from these integers. Open the

Use C++ programming in below two problems.

Problem G1

This program will read integers from a file and find results from these integers.

Open the file, test to make sure the file opened. Use a loop to read the integers and process each integer as it is read. When End Of File is reached, close the file.

After all of the integers have been read and processed, print the results for the following output:

  • The integer count:
  • The sum of the integers:
  • The smallest integer:
  • The largest integer:
  • The average of the integers:

Use notepad, vim, or other simple text editor to create a file named file1.txt containing the following, with one integer per line.

Test the program two times.

Use the following data in the first test:

11 9 18 22 27 33 21 

For the second test add an additional line containing the number 40.

Problem G2

Write two functions: A function named sum which takes two integer values as arguments, and returns their sum. A main function which asks the user for two integer values, passes the two values to the sum function, then prints the two values and their sum. The main function then again asks the user for two integer values, passes the two values to the sum function, then prints the two values and their sum.

Test it once, with the values 3 and 4, and then 5 and 49.

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

Recommended Textbook for

Database Processing Fundamentals, Design, and Implementation

Authors: David M. Kroenke, David J. Auer

14th edition

133876705, 9781292107639, 1292107634, 978-0133876703

Students also viewed these Databases questions

Question

Knowledge of process documentation (process flow charting)

Answered: 1 week ago