Write a C++ program to get names of countries into an array and show them based on Lowest number of characters.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | #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