Question

Hello, I need the pseudocode / flowchart for the following : read input from a file...

Hello, I need the pseudocode / flowchart for the following :

read input from a file by adding all the numbers in a file to an array, then iterate through the array to count how many times each number appears in the array (the frequency of each number) - then write the summation results to a file: summary.txt.

Need to use a numbers.txt file that looks like this:

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Pseudocode of above-given program step by step.

Step 1:

Create a file pointer to read the file and iterate over its contents till EOF. // fptr = fopen(filename, "r"); //in C

Step 2:

While iterating, add file content(numbers) to the array and increment array index.

//Till this step number list has been added to the array.

Step 3:

Iterate over the array to find the maximum element (say m) of them and declare a new array count with the m+1 size and initialize it to 0s.

Step 4:

Again iterate over the array arr and increment the "arr[i]" position by 1 in new array count. In this way, array count has the frequency of all elements of arr.

Step 5:

Now array can be iterated for summing its numbers.

for(int i=0; i<(sizeof(arr)/sizeof(int);i++){sumofnum=sumofnum+arr[i];}

Step 6:

The variable till now contains ths summation of whole array. Now it can be written to new file with name "summary.txt" , //fptr = fopen("summary.txt","w");/in C

You can also do the frequency count in two loops that would be simple , longer, and will have high time complexity O(n2)

Add a comment
Know the answer?
Add Answer to:
Hello, I need the pseudocode / flowchart for the following : read input from a file...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Hello, I need the array pseudocode for the following: "take input from the user on what...

    Hello, I need the array pseudocode for the following: "take input from the user on what value they want to search for, then if that value is found - output that the value is found and what index number it is contained in, otherwise output that the value is not found."

  • Arrays and reading from a file USE C++ to write a program that will read a...

    Arrays and reading from a file USE C++ to write a program that will read a file containing floating point numbers, store the numbers into an array, count how many numbers were in the file, then output the numbers in reverse order. The program should only use one array and that array should not be changed after the numbers have been read. You should assume that the file does not contain more than 100 floating point numbers. The file name...

  • C++ need #7 and #8 6. Write code that does the following: Opens an output file...

    C++ need #7 and #8 6. Write code that does the following: Opens an output file with the filename Numbers.txt, uses a loop to write the numbers 1 through 100 to the file, and then closes the file. ofstream outputFile("Numbers.txt"); for(int number = 1; number <= 100; number++) outputFile<< number << endl; outputFile.close(); 7. Write code that does the following: Opens the Numbers.txt file that was created by the code you wrote in question 6, reads all of the numbers...

  • For your second program, please read the data from the input file directly into an array....

    For your second program, please read the data from the input file directly into an array. (You may safely dimension your array to size 300.) Then close the input file. All subsequent processing will be done on the array. Your program should have two functions besides main(). The first function will print out the contents of the array in forward order, 10 numbers per line, each number right justified in a 5 byte field. The second function will print out...

  • Create a Raptor Flowchart and Pseudocode for the following: That searches an array of size 15...

    Create a Raptor Flowchart and Pseudocode for the following: That searches an array of size 15 that holds a collection of numbers, for the value 7. First we take input from the user to fill each element in the array. Then we search the array for value 7. If value 7 is not found we output: "Value 7 is not contained in array[]", otherwise if the value 7 is found output: "Value 7 is contained in array[] at index" and...

  • I need help in Python. This is a two step problem So I have the code...

    I need help in Python. This is a two step problem So I have the code down, but I am missing some requirements that I am stuck on. Also, I need help verifying the problem is correct.:) 7. Random Number File Writer Write a program that writes a series of random numbers to a file. Each random number should be in the range of 1 through 500. The application should let the user specify how many random numbers the file...

  • Write a C++ that read a list of numbers from a .txt file into array. The...

    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...

  • Hello Sir, I need help with Java. Here is the problem below. Problem 1.Write a program...

    Hello Sir, I need help with Java. Here is the problem below. Problem 1.Write a program that prompts the user to enter the number of milliseconds and converts the milliseconds to a string hours:minutes:seconds. The program should use the convertMillismethod with the following header: public static String convertMillis(long millis) For example, convertMillis(5500) returns the string 0:0:5, convertMillis(100000) returns the string 0:1:40, and convertMillis(555550000) returns the string 154:19:10. Problem 2. (Count occurrence of numbers)Write a program that reads integers between 1...

  • Description: Create a program called numstat.py that reads a series of integer numbers from a file...

    Description: Create a program called numstat.py that reads a series of integer numbers from a file and determines and displays the name of file, sum of numbers, count of numbers, average of numbers, maximum value, minimum value, and range of values. Purpose: The purpose of this challenge is to provide experience working with numerical data in a file and generating summary information. Requirements: Create a program called numstat.py that reads a series of integer numbers from a file and determines...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT