0% found this document useful (0 votes)
17 views2 pages

Waseem Ali Alzhrani H.W1.22

This document defines a template function called "maximum" that takes in three values of any type T and returns the maximum value. It uses the template to find the maximum of three integer, double, and character values by calling the maximum function on sample inputs.

Uploaded by

alzhranymhmd521
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views2 pages

Waseem Ali Alzhrani H.W1.22

This document defines a template function called "maximum" that takes in three values of any type T and returns the maximum value. It uses the template to find the maximum of three integer, double, and character values by calling the maximum function on sample inputs.

Uploaded by

alzhranymhmd521
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

waseem ali alzhrani //

443034275 //

HomeWork1 : Function template //

> include <iostream#

;using namespace std

> template <class T

T maximum (T V1, T V2, T V3)

;T maximumValue = V1

if ( V2 > maximumValue )

;maximumValue = V2

if ( V3 > maximumValue )

;maximumValue = V3

; return maximumValue

) (int main

;int I1, I2, I3

; "cout << "Input three integer values:\n

;cin >> I1 >> I2 >> I3

;cout << "The maximum integer value is:" << maximum ( I1, I2, I3 )
;double D1, D2, D3

; "cout << "\n\nInput three double values:\n

;cin >> D1 >> D2 >> D3

;cout << "The maximum double value is:" << maximum ( D1, D2, D3 )

;char C1, C2, C3

; "cout << "\n\nInput three characters:\n

;cin >> C1 >> C2 >> C3

;cout << "The maximum character value is:" << maximum ( C1, C2, C3 ) << endl

;return 0

You might also like