#include<iostream>#include<string>#include<cctype>usingnamespace std;voidToupper(string &str);intmain(){
string str;
cout <<"Enter a string (q to quit):";getline(cin, str);while(str !="q"){Toupper(str);
cout << str << endl;
cout <<"Next string(q to quit):";getline(cin, str);}
cout <<"Byebye!"<< endl;return0;}voidToupper(string& str){for(int i =0; i < str.size(); i++){
str[i]=toupper(str[i]);}}
#include<iostream>#include<cstring>#include<string>usingnamespace std;structstringy{char* str;int ct;};voidset(stringy& str,constchar* ch);voidshow(const stringy& str,int n =1);voidshow(constchar* ch,int n =1);intmain(){
stringy beany;char testing[]="Reality isn't what it used to be.";set(beany, testing);show(beany);show(beany,2);
testing[0]='D';
testing[1]='u';show(testing);show(testing,3);show("Done!");return0;}voidset(stringy& str,constchar* ch){int num =strlen(ch)+1;
str.str =newchar[num];strcpy_s(str.str, num, ch);
str.ct =strlen(str.str);}voidshow(const stringy& str,int n){for(int i =0; i < n; i++){
cout << str.str <<" "<< str.ct << endl;}}voidshow(constchar* ch,int n){for(int i =0; i < n; i++)
cout << ch << endl;}
#include<iostream>usingnamespace std;template<typenameT>
T max5(T num[]);intmain(){int num1[5]={5,8,4,9,6};double num2[5]={5.3,4.8,3.9,10.8,1.2};
cout <<max5(num1)<< endl;
cout <<max5(num2)<< endl;return0;}template<typenameT>
T max5(T num[]){
T max = num[0];for(int i =1; i <5; i++){if(num[i]> max){
max = num[i];}}return max;}
#include<iostream>#include<cstring>usingnamespace std;template<typenameT>
T max5(T num[],int n);template<>char*max5(char* ch[],int n);intmain(){int num1[6]={5,8,4,9,6,16};double num2[4]={5.3,4.8,3.9,10.8};constchar* ch[5]={"Nice to meet you.","I love you,Rick.","Go away.","Good grief.","Good moring"};
cout <<max5(num1,6)<< endl;
cout <<max5(num2,4)<< endl;
cout <<max5(ch,5)<< endl;return0;}template<typenameT>
T max5(T num[],int n){
T max = num[0];for(int i =1; i < n; i++){if(num[i]> max){
max = num[i];}}return max;}template<>char*max5(char* ch[],int n){int pos =0;for(int i =1; i < n; i++){if(strlen(ch[i])>strlen(ch[pos])){
pos = i;}}return ch[pos];}