Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program that defines a template functionnamed add(). This function takes

ID: 3608491 • Letter: W

Question

Write a program that defines a template functionnamed add(). This function takes two arguments,add two variables and then return the sum.

In main function, define two variables of typeint, two variables of type float and two objects of type‘String’. Now call the add() function three times forthese different data types.

Note: String is auser-defined data type and for this you have to define a classnamed ‘String’. When template function will be calledto add two objects of type String then it must concatenate twostrings.

Your output should look like this:

SampleOutput:

Enter two integer values to be added

Enter First value:12

Enter Second value:25

Enter two float values to be added

Enter First value:13.5

Enter Second value:14.2

Enter two Strings to be added

Enter First value:Virtual

Enter Second value:University

Addition of two variables of different datatypes

Sum of values of type int = 37

Sum of values of type float = 27.7

Sum of values of type String =VirtualUniversity

Write a program that defines a template functionnamed add(). This function takes two arguments,add two variables and then return the sum.

In main function, define two variables of typeint, two variables of type float and two objects of type‘String’. Now call the add() function three times forthese different data types.

Note: String is auser-defined data type and for this you have to define a classnamed ‘String’. When template function will be calledto add two objects of type String then it must concatenate twostrings.

Your output should look like this:

SampleOutput:

Enter two integer values to be added

Enter First value:12

Enter Second value:25

Enter two float values to be added

Enter First value:13.5

Enter Second value:14.2

Enter two Strings to be added

Enter First value:Virtual

Enter Second value:University

Addition of two variables of different datatypes

Sum of values of type int = 37

Sum of values of type float = 27.7

Sum of values of type String =VirtualUniversity

Explanation / Answer

Write a program that defines a template functionnamed add(). This function takes

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote