Write the program of function templates, C/C++ Programming

Assignment Help:

Consider the following example:

int max(int x, int y)

                 {

                                return ( x > y) ? x : y ;

                 }

 

float max(float x, float y)

                 {

                                return ( x > y) ? x : y ;

                 }

 

 long max( long x,  long y)

                 {

                return ( x > y) ? x : y ;

                 }

 

char max(char x, char y)

                 {

                                return ( x > y) ? x : y ;

                 }

                void main()

                {

                  cout << max( 1,2) << endl;

                  cout << max( 4L,3L) << endl;

                  cout << max( 5.62,3.48) << endl;

                  cout << max('A','a') << endl;

                }


The output is :

                                                2

                                                4

                                                5.62

                                                a

 


Related Discussions:- Write the program of function templates

Program to sort a range of numbers with insertion, Program to sort a range ...

Program to sort a range of numbers with Insertion: /* define variable */ const int max=29000; int list[max]; FILE *fp; clock_t start,end; char any1[8];

Declaration of variables in cpp, Declaration of Variables: Variables ar...

Declaration of Variables: Variables are declared as follows: int a; float b;   Assigning value to variables: int a = 100; Declaring and assigning is called ini

Program to find a greatest string: c - program , Program to find a Greatest...

Program to find a Greatest String: C - Program: Write a program find largest string by c program. int main( int argc, char *argv[] ) {     if( argc         {

C program that controls the uart, Objective: Construct a C program tha...

Objective: Construct a C program that controls the UART, and is capable of displaying strings. Echo characters received on the UART to the LCD screen Outcome: A mess

Minimum total number of shelves, At a shop of marbles, packs of marbles are...

At a shop of marbles, packs of marbles are prepared. Packets are named A, B, C, D, E …….. All packets are kept in a VERTICAL SHELF in random order. Any numbers of packets with thes

What is default argument, Default argument: When the argument is missin...

Default argument: When the argument is missing then the function will read the default value of the missing argument.  To make use of default argument functionality the argu

C program to print fibonacci series upto n using recursion, C program to Pr...

C program to Print Fibonacci series upto n using recursion: int fibo(long int); void main() {                 long int a=0,n;                 printf ("how many term

Padovan string, write a program that counts the number of occurrences of th...

write a program that counts the number of occurrences of the string in the n-th padovan string p(n)   program 1 : package test.padovanstring; public class PadovanString {

Writing a c++ program, how can I write a c++ program that generate all evn ...

how can I write a c++ program that generate all evn numbers less than 1000?

Change to palindrome, A palindrome is a string that reads the same from bot...

A palindrome is a string that reads the same from both the ends. Given a string S convert it to a palindrome by doing character replacement. Your task is to convert S to palindrome

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd