Count the Number of Items (Id-1491)

Just for Practice 6 Additional [26-Feb-2018 to 3-Mar-2018]

CSE1002 Bonus Practice Sheet Winter 2018__Batch 3 [17-Mar-2018 to 7-Apr-2018]

Program ID- 1491

Given a collection of elements and a value specifying a value to be checked, develop a generic function count the number of elements with the value. Use the function to check a collection of primitive data types such as integers, floating point values and characters. Also given a set of books in a library and the name of the book to be searched, use the generic function to count the number of books in the library with the given name. Use predefined string class for representing name of the book, ‘==’ operator is overloaded in predefined class string to check if two strings are same.

Input Format:

Choice of type of input (0- int, 1 – char, 2- book)

The first line will contain the number of elements ‘n’

The next ‘n’ lines will contain the details of each element

If the elements are of type book then the order of details are:

book id, book name, author name and cost

Element to be searched

Output Format:

Count of elements in the collection

Code

Please Comment Working if the code worked to you

If you have other working codes please comment the codes enclosing with <pre> and </pre> 🙂

Example: <pre> Your Code </pre>

C++ Code 

The Above Codes are for reference only. It doesn't mean everyone to directly copy/paste those codes.

 

Click Here to Leave a Comment Below 0 comments

Leave a Reply:

This site uses cookies and by using the site you are consenting to this.