Problem Solving with C++ (10th Edition)
Problem Solving with C++ (10th Edition)
10th Edition
ISBN: 9780134448282
Author: Walter Savitch, Kenrick Mock
Publisher: PEARSON
bartleby

Concept explainers

Question
Book Icon
Chapter 18, Problem 2P
Program Plan Intro

Histogram of positive numbers

Program Plan:

  • Include required header file.
  • Include required “std” namespace.
  • Define main function
    • Declare a variable in “map” template class.
    • Initializes the variable “numbers” to “0”.
    • Display prompt statement.
    • Performs “while” loop. This loop will perform upto “numbers” equal to “-1”.
      • In this loop, first read the number from user.
      • If the number is not equal to “-1”, then check if the number is in map or not using “find” function.
        • If it is, then assign “mapResult[numbers]” is “1”.
        • Otherwise, increment the counter
    • Declare constant iter “result” in “map” template class.
    • Display the given result using “for” loop.

Blurred answer
Students have asked these similar questions
mergeAndRemove(int[], int[]) This is a public static function that takes a int[] and int[] for the parameters and returns an int[]. Given two arrays of integers. Your job is to combine them into a single array and remove any duplicates, finally return the merged array.
A. write a code to find the number of students who pass CS course, when their marks>=40 . As thelist has 85 students. B. wite a code to print this shape: *** *** **** C. Write a code to find the area and parameter of a Tringle; Area =1/2 * High * BaseParameter= S1+S2+ Base
Template Specialization in c++ is used to write generic code. Template code is written once and use for any data type including user-defined data types.Example: sort() can be written and used to sort any data type items. Create a Template code that reads input from the user, user can enter any type of data like integer, double, float.sum() is the template method that can take any two types of data and add it and return the sum of the two numbers.Create a Template Specialization method to add two integer values only.If a specialized version is present, the compiler first checks with the specialized version and then the main template.  Sample Input  and Output:Enter two integer Numbers: 55Enter two float Numbers: 3.53.1Enter two double Numbers: 3.68.6Sum of two integer Numbers: only integer10Sum of two float Numbers: 6.6Sum of two double Numbers: 12.2
Knowledge Booster
Background pattern image
Computer Science
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
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education