Create a function called surprise_function () which takes in two integers and adds them together. You will then create the following overloaded versions, which should do different things based on the data type passed in:      Data Type Operation      Integer Addition Float Division Double Modulus Char Concatenation (Return as String) Boolean Result of AND You should prompt the user for what data type they want to enter, then ask for two values of that data type. Then, call surprise_function (), pass in the values, store the result in an appropriate variable, then print the variable. Note: You must make overloaded functions for this assignment – they must all be called surprise_function (). You can not create unique, non-overloaded functions like surprise_function_booleans(). Dynamic Arrays for C++ .  There are several popular compilers, but there are a few key differences between what they will and won’t allow you to do in C++. In some compilers, the following code is perfectly fine: int i = 12; int array[i]; Other compilers will throw an error because you are not using a constant to define the size of the array. This limitation obviously poses a challenge to completing certain assignments. If your compiler does not allow you to use variables to define arrays, use the following workarounds: For 1D Arrays int x = 12; int * array = new int[x]; For 2D Arrays int x = 12; int y = 24; int ** array = new int * [x]; for(int i = 0; i < x; i++){ array[i] = new int[y]; } Once you have done so, you can use the arrays as normal (e.g. array[0][0] = 34 will assign the array at index 0, 0 to the value of 34).

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

Create a function called surprise_function () which takes in two integers and adds them together. You will then create the following overloaded versions, which should do different things based on the data type passed in:

     Data Type Operation
     Integer Addition
Float Division
Double Modulus
Char Concatenation (Return as String)
Boolean Result of AND

You should prompt the user for what data type they want to enter, then ask for two values of that data type. Then, call surprise_function (), pass in the values, store the result in an appropriate variable, then print the variable.

Note: You must make overloaded functions for this assignment – they must all be called surprise_function (). You can not create unique, non-overloaded functions like surprise_function_booleans().

Dynamic Arrays for C++ .  There are several popular compilers, but there are a few key differences between what they will and won’t allow you to do in C++.

In some compilers, the following code is perfectly fine:

int i = 12;

int array[i];

Other compilers will throw an error because you are not using a constant to define the size of the array. This limitation obviously poses a challenge to completing certain assignments. If your compiler does not allow you to use variables to define arrays, use the following workarounds:

For 1D Arrays

int x = 12;

int * array = new int[x];

For 2D Arrays

int x = 12;

int y = 24;

int ** array = new int * [x];

for(int i = 0; i < x; i++){

array[i] = new int[y];

}

Once you have done so, you can use the arrays as normal (e.g. array[0][0] = 34 will assign the array at index 0, 0 to the value of 34). 

Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Array
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