Write a C++ program to search an element in an array using a function template.   Note: Define an array size using Preprocessor directives Example:  #define array_size 5   Strictly adhere to the Object-Oriented specifications given in the problem statement. All class names, member variable names, and function names should be the same as specified in the problem statement.   Include following member function using Template Function Name Description T SearchInArray(T x[], T element)                                              This function is used to search an element in an array. If the element is found it returns true otherwise false.   include in function:- If an element is found in an array then print "Element # is found" otherwise "Element # is not found. (Eg. Element 4 is found)   In the main method, read the array elements and search for an element in the array. Input and Output Format: Refer sample Input and output for formatting specifications.   Sample Input and Output: [ All text in bold corresponds to input and the rest corresponds to output ] Enter 5 integer numbers 9 2 4 10 5 Enter element to search: 4 Element 4 is found Enter 5 float numbers 3.7 4.9 8.2 5.1 6.3 Enter element to search: 8.9 Element 8.9 is not found

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 to search an element in an array using a function template.
 
Note: Define an array size using Preprocessor directives
Example:  #define array_size 5
 
Strictly adhere to the Object-Oriented specifications given in the problem statement. All class names, member variable names, and function names should be the same as specified in the problem statement.
 
Include following member function using Template
Function Name Description

T SearchInArray(T x[], T element)                                             

This function is used to search an element in an array. If the element is found it returns true otherwise false.

 

include in function:- If an element is found in an array then print "Element # is found" otherwise "Element # is not found. (Eg. Element 4 is found)

 
In the main method, read the array elements and search for an element in the array.

Input and Output Format:

Refer sample Input and output for formatting specifications.
 
Sample Input and Output:
[ All text in bold corresponds to input and the rest corresponds to output ]
Enter 5 integer numbers
9
2
4
10
5
Enter element to search:
4
Element 4 is found
Enter 5 float numbers
3.7
4.9
8.2
5.1
6.3
Enter element to search:
8.9
Element 8.9 is not found
Expert Solution
steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
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