Write a C++ program to get names of countries into an array and show them based on highest number of characters.
#include<bits/stdc++.h>
using namespace std;
// Function to check for the small string
bool increasing(string T4Tutorials,string T4Tutorials2)
{
if(T4Tutorials.length()>T4Tutorials2.length())
return 1;
else return 0;
}
// Driver Code
int main()
{
string T4Tutorials1[]={"Pakistan","India ","United States","United Kingdom","Australia","Italy","China"};
int n = sizeof(T4Tutorials1)/sizeof(T4Tutorials1[0]);
// Function to perform sorting
sort(T4Tutorials1 , T4Tutorials1 + n , increasing);
for(int i=0;i<n;i++)
std::cout << T4Tutorials1[i] << std::endl;
return 0;
}
Output
United Kingdom
United States
Australia
Pakistan
India
Italy
China
Similar Problems
- C++ program to show countries into an array according to Lowest number of characters
- C++ program to show countries into an array according to Largest number of characters
- C++ program to show weekdays into an array according to Lowest number of characters
- C++ program to show weekdays into an array according to Highest number of characters
Similar Problems
- C++ program to show countries into an array according to Lowest number of characters
- C++ program to show countries into an array according to Largest number of characters
- C++ program to show weekdays into an array according to Lowest number of characters
- C++ program to show weekdays into an array according to Highest number of characters
