Problem A: Computing statistics on a data set. Write a program that reads a list
ID: 3679927 • Letter: P
Question
Problem A: Computing statistics on a data set. Write a program that reads a list of integers stored in a file and computes a count of how many times each number occurs in the data set. Specifically, your program should compute a count of how many times each integer number stored in the file occurs, and compute the average, minimum and maximum value for the numbers stored in the file You may assume that there is at least one number stored in the file, and that each value x in stored in the input file will range between 0 and 99 (so, algebraically: 0Explanation / Answer
#include <stdio.h>
#include <string.h>
#define SIZE 100
int main(void) {
int count=0;
char *pch=NULL;
char line[SIZE];
char target[SIZE]={"20"};
FILE *fp=fopen("countNumber.txt","r");
if(!fp) {
printf("Error unable to open the file ");
return 0;
}
while(fgets(line, SIZE, fp)){
pch=&line[0];
while((pch=strstr(pch,target)) != NULL) {
//printf("%s ",pch++); getchar();
count++;
}
}
fclose(fp);
printf("target string %s was found %d times ",target, count);
return 0;
}
In java this is my code :-
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.