Write a C program that reads integer values from stdin, separated by one or more spaces or newlines, until reaching EOF.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Write a C program that reads integer values from stdin, separated by one or more spaces or newlines, until reaching EOF.

 Once we have entered all our integers, we may have to press Enter before pressing Ctrl+d.
 This signifies that we do not have to create a function, we can implement this vertical histogram

program within our main(...) function.
 Save your program as verticalHistogram.c

  •   The input contains no more than 80 values.
     Why? Because a standard terminal window is 80 character-columns across.

  •   The input is guaranteed to be well-formed.

  •   On standard output (stdout), it renders a simple vertical column graph representation of the input values (i.e., a vertical histogram), in order left to right, using hash '#' characters as shown in the examples on the next slides. The number of hashes '#' printed in each column

    should be equal to the corresponding input value.

     

 The area above a completed column should be filled with space characters. 

 Ignore empty lines in the input. Do not output a column for an empty line in the input.

 The entire graph must end with a newline character.  Hint:

 In order to plot a histogram vertically, we need to have finished reading all the input before we start drawing the histogram on stdout. An array is suitable for this.

 If we limit the number of columns we can graph to a maximum of 80, we know how large an array we need to allocate and this program is simple to write.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Algebraic Expressions
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education