How would you write a program to create a frequency table from entering 20 numbers in pascal for numbers 1-5?
-
Basically, how would one write a program in pascal language, using arrays to create a frequency table from the numbers entered? So the user would input 20 numbers, (from 1-5) and then the output would be something like 1 5 2 7 3 8 4 0 5 0
-
Answer:
You can do this: procedure FreqTable; var i,j : integer; ftable : array [0..4] of integer; begin // reset the array values to 0 for i := 0 to 4 do ftable[i] := 0; for i := 0 to 19 do begin readln(j); if (ftable > 5) then continue; ftable[j - 1] := ftable[j - 1] + 1; end; // display the contents of the frequency table array for i := 1 to 5 do writeln(i, ftable[i - 1]); end; This procedure is basic at best. It always assumes that there are 20 numbers being entered.
Phillip Flores at Quora Visit the source
Related Q & A:
- How do you pause a program until a button is pressed in JAVA?Best solution by Stack Overflow
- How to write a program to monitor the temperature of CPU?Best solution by Stack Overflow
- What is Hash Table, how to create a hash table?Best solution by Stack Overflow
- How do I write a resume for a part-time job?Best solution by Yahoo! Answers
- How to write a persuasive letter to a bank?Best solution by wikihow.com
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.