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 weekdays,string weekdays2)
{
if(weekdays.length()<weekdays2.length())
return 1;
else return 0;
}
// Driver Code
int main()
{
string weekdays1[]={"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"};
int n = sizeof(weekdays1)/sizeof(weekdays1[0]);
// Function to perform sorting
sort(weekdays1 , weekdays1 + n , increasing);
for(int i=0;i<n;i++)
std::cout << weekdays1[i] << std::endl;
return 0;
}
Output
Monday
Friday
Sunday
Tuesday
Thursday
Saturday
Wednesday
——————————–
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
