Using C++,
Write a program that will search a file filled with numbers, and show the largest number and the smallest number. The program will also count how many of the numbers are even (evenly divisible by two). Use the file data71.txt.
File data71.txt numbers:
23
56
78
90
34
123
456
789
986
543
1104
2
4
7
543
124
Please find the code below:
#include <iostream>
#include <string>
#include <fstream>
#include <sstream>
using namespace std;
int main( )
{
ifstream infile;
infile.open ("data71.txt"); //name of file here. plz
mention Complete path if file is not at root
int min = 9999;
int max = 0;
int temp;
int evenCount =0;
int totalNumberCount = 0;
if (infile.is_open()) //if file opened
{
while(infile>>temp ) { //get
row from text file
if(min>temp){
min=temp;
}
if(max<temp){
max=temp;
}
if(temp%2==0){
evenCount++;
}
totalNumberCount++;
}
infile.close(); //close file
cout<<"File scan
done........"<<endl;
}
else //if file not found show the below message
{
cout << "Sorry, we could not
find the file." << endl;
}
cout<<"Total number count :
"<<totalNumberCount<<endl;
cout<<"Total even number count :
"<<evenCount<<endl;
cout<<"Minimum number is :
"<<min<<endl;
cout<<"Maximum number is :
"<<max<<endl;
return 0;
}
data71.txt
23
56
78
90
34
123
456
789
986
543
1104
2
4
7
543
124
output:
![console X terminated> CPP Workspace.exe [C/C++ Application] CAU Total number count 16 Total even number count : 10 Maximum number is: 1104 if file is not](http://img.homeworklib.com/questions/b6189ae0-6446-11eb-bcec-5f646c06f3ce.png?x-oss-process=image/resize,w_560)
Using C++, Write a program that will search a file filled with numbers, and show the...
Write a program in C that reads 20 float numbers from a file. The values are stored in a vector (1-dimensional array). Find and display the smallest number, the second smallest number, and the third smallest number of the set. Use only these libraries: stdio.h, stdlib.h, math.h, and string.h. Below is an example of the input file (in1.txt) and the resulting output file (output.txt). In1.txt: 3.14 4.05 -3.73 4.13 1.32 -2.21 0.46 4.57 4.64 -3.42 4.57 -0.14 3.00 -3.58 -0.78...
Write a program that reads an integer k from user and finds the number of elements that are divisible by k in the file assignment4.txt. A number n is divisible by k if n = kx for some integer x > 0. You can use the mod operator % to test for divisibility. The file assign4.txt has integer values in the range [0,100 ]. You should use end-of-file controlled loop for this problem. Sample execution is given below. Assume the...
JAVA HW Write a program that will search a text file of strings representing numbers of type int and will write the largest and the smallest numbers to the screen. Include appropriate error handling in case a line contains more than one int or it contains a String. Wrap all the work you are doing with the file in a try/catch/finally block with appropriate "catch" sections; the finally block will be where you close your file object (if desired, look...
write program above in C only
Write a program to find statistics on some random numbers. Seed the random number generator with time. In a for loop generate 12 random numbers between the values of 2 and 20. Print the numbers. As the numbers are generated, find the following: the number of even numbers (those evenly divisible by 2) e the sum of the even numbers the product of the even numbers the maximum value of all the numbers e
1. write a java program using trees(binary search treee) to read integers from input file( .txt) and add +1 to each number that you read from the input file. then copy result to another (.txt) file. example: if inpu File has numbers like 4787 79434 4326576 65997 4354 the output file must have result of 4788 79435 4326577 65998 4355 Note: there is no commas in between the numbers. dont give images or theory please.
Write a C++ that read a list of numbers from a .txt file into array. The first digit on the list will be array size, while the second number on the list will be our first number in our array list. Example: t1.txt file contain list off input number: 5, 3, 6, 10, 43, 23. notice the first number is 5 which will need to be use as an array size and the rest of the numbers are in the...
Use C++
For this week’s lab you will write a program to read a data file
containing numerical values, one per line. The program should
compute average of the numbers and also find the smallest and the
largest value in the file. You may assume that the data file will
have EXACTLY 100 integer values in it. Process all the values out
of the data file. Show the average, smallest, largest, and the name
of the data file in the...
Write a program **(IN C)** that displays all the phone numbers in a file that match the area code that the user is searching for. The program prompts the user to enter the phone number and the name of a file. The program writes the matching phone numbers to the output file. For example, Enter the file name: phone_numbers.txt Enter the area code: 813 Output: encoded words are written to file: 813_phone_numbers.txt The program reads the content of the file...
Write a C program to assign natural numbers 1 to 100 into a one-dimensional integer array. Display all the values in the array on the screen. For each number in the array, determine if the number contains digit 7 or is divisible by 7. Display all those numbers on the screen. Original array: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27...
C++ Manually create a file Numbers.txtand fill it with integers, one below the other. Write a program that reads ANY sequence of integers (can be positive, 0 or negative) from this file. Using a looping construct, you will read numbers from the file till end of the file is reached. Calculate the largest and the smallest numbers among the data in the file. Your code must display both of those on the terminal screen along with total count of numbers...