LabExam1Soln - A histogram is a graphical display of...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
A histogram is a graphical display of tabulated frequencies, shown as bars. An example of a histogram You should complete a program that asks the user for limits of 5 bins, reads data from a file and prints the histogram. Example of the run: Enter 4 limits of bins 0 1 2 3 Enter the name of the data file : data.txt -INF- 0 :*** 0- 1 :******* 1- 2 :*** 2- 3 :*** 3- +INF :** data.txt -1 -1 1.2 1.2 1.4 0.1 0.2 -.1 0.1 0.2 0.3 0.1 0.4 2.2 2.2 2.3 5 6 The incomplete program looks as follows: #include <iostream> #include <iomanip> #include <fstream> using namespace std;
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
const int TOTAL_BINS=5; void add_point( double x, int bins[], double limits[]); void print_hist( int bins[], double limits[]); bool read_data( char name[], int bins[], double limits[]); int main() { double limits[TOTAL_BINS-1]; int bins[TOTAL_BINS]; cout<< "Enter " <<TOTAL_BINS-1<< " limits of bins" <<endl; for ( int i=0;i<TOTAL_BINS-1;i++) { cin>>limits[i]; } char file[80]; do { // try to read data from file // until user enters valid file name
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 09/05/2011 for the course CGS 2421 taught by Professor Onal during the Fall '09 term at University of Florida.

Page1 / 6

LabExam1Soln - A histogram is a graphical display of...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online