Given the string variables name1 and name2, write a fragment of code that assigns the larger of the two to the variable first (assume all three are already declared and name1 and name2 assigned values ).

LANGUAGE: C++

CHALLENGE:

Given the string variables name1 and name2, write a fragment of code that assigns the larger of the two to the variable first (assume all three are already declared and name1 and name2 assigned values ).

SOLUTION:



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