Given the char * variables name1 , name2, and name3, write a fragment of code that assigns the largest value to the variable max (assume all three have already been declared and have been assigned values ).

LANGUAGE: C++

CHALLENGE:

Given the char * variables name1 , name2, and name3, write a fragment of code that assigns the largest value to the variable max (assume all three have already been declared and have been assigned values ).

SOLUTION:



max=name1;
if (strcmp(name2, max)>0){
    max=name2;
}

if (strcmp(name3,max)>0){
    max=name3;
}