Discussion
A program P reads in 500 integers in the range [0..100] representing the scores of 500 students. It then prints the frequency of each score above 50. What would be the best way for P to store the frequencies?
Answer: A
Correct answer: An array of 50 numbers
Only scores above 50 are to be reported, and the scores run from 0 to 100. That leaves the 50 values 51, 52, …, 100, so an array of 50 counters is enough - score \(s\) increments the cell at index \(s - 51\). Arrays of 100, 500 or 550 would work but waste space; the question asks for the best choice.
No comment is present. Be the first to comment.
Loading…
Post your comment
Please log in or register to post a comment.
Examination Categories
- SSC Exams
- Banking Exams
- Teaching Exams
- Civil Services Exams
- Railways Exams
- Engineering Recruitment Exams
- Defence Exams
- State Government Exams
- Police Exams
- Insurance Exams
- Nursing Exams
- Other Government Exams
- NRA CET
- PG Entrance Exams
- Campus Placement
- MBA Entrance Exams
- CUET and UG Entrance
- Judiciary Exams
- Regulatory Body Exams
- Software Development