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