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