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

Download the file HugeFile.dat This file contains a very large number of integer

ID: 3761287 • Letter: D

Question

Download the file HugeFile.dat This file contains a very large number of integers. The number of values per line varies.

      Write a C++ program to read the file (assume that you do not know the number of values in the file) and determine (and display) each of the following:

The number of values in the file

The largest value in the file

The smallest value in the file

The number of even numbers in the file

The number of values in the file that are greater than 80

The number of values in the file that are less than or equal to 30

***the numbers in the file named hugefile.dat is irrelevant but ur experts so u prolly already know that.

Thank you! :)

Explanation / Answer

#include <fstream>
#include <iostream>
#include<limits.h>
using namespace std;


int main(){
   ifstream infile;
   infile.open("HugeFile.dat");
   int num;
   int count = 0,largest = 0, smallest = INT_MAX,evenNumbers = 0,greaterThan80 = 0,lessThan30 = 0;
   while (infile >> num){
       count++;
       if(num > largest)
           largest = num;
       if (num < smallest)
           smallest = num;
       if(num % 2 == 0 )
           evenNumbers++;
       if(num > 80)
           greaterThan80++;
       if(num <= 30)
           lessThan30;  
   }
  

  
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote