Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

c++ using the file name \"integers.dat\" CHA PTER 6/ VO Streams as an Introducti

ID: 3601567 • Letter: C

Question



c++
using the file name "integers.dat"

CHA PTER 6/ VO Streams as an Introduction to Objects and Classes Note that you should use isupper (next) and not use This is because islower (next) is false if next c not a letter (such as the blank or comma symbol). contains a character that is PRACTICE PROGRAMS Practice Programs can generally be solved with a short program that directl the programming principles presented in this chapter 1. Write a program that will search a file of numbers of type int and write the largest and the smallest numbers to the screen. The file contains nothing but numbers of type int separated by blanks or line breaks. If this is being done as a class assignment, obtain the file name from your instructor. 2. Write a program that takes its input from a file of numbers of type double The file and outputs the average of the numbers in the file to the screen. contains nothing but numbers of type double separated by blanks and ot line breaks, If this is being done as a class assignment, obtain the file nanmt from your instructor 3. a. Compute the median of a data file, The median i has the same the number that

Explanation / Answer

1)

#include<fstream>

#include<iostream>

using namespace std;

int main()

{

ifstream fin;

int ch;

fin.open("integers.dat");//enter name of file

fin>>ch;

int min=ch;

int max=ch;

while(fin>>ch)

{

if (ch>max)

max=ch;

if(ch<min)

min=ch;

}

cout<<"Largest:"<<max<<endl;

cout<<"Smallest:"<<min;

fin.close();

return 0;

}

2)

#include<fstream>

#include<iostream>

using namespace std;

int main()

{

ifstream fin;

double ch;

fin.open("integers.dat");//enter name of file

double sum=0,n=0;

while(fin>>ch)

{

n=n+1;

sum=sum+ch;

}

cout<<"Average:"<<sum/n<<endl;

fin.close();

return 0;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote