write a c++ program that reads ten strings and store them in array of strings, sort them and finally print the sorted strings code example

Example 1: write a c++ program that reads ten strings and store them in array of strings, sort them and finally print the sorted strings

void sortString(string &str) 
{ 
   sort(str.begin(), str.end()); 
   cout << str; 
} 
  
// Driver program to test above function 
int main() 
{ 
    string s = "geeksforgeeks";  
    sortString(s);  
    return 0; 
}

Example 2: write a c++ program that reads ten strings and store them in array of strings, sort them and finally print the sorted strings

void sortString(string &str) 
{ 
   sort(str.begin(), str.end()); 
   cout << str; 
} 
  
// Driver program to test above function 
int main() 
{ 
    string s = "geeksforgeeks";  
    sortString(s);  
    return 0; 
}

Tags:

Cpp Example