Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int main()
- {
- char str[5][20], t[20];
- int i, j;
- cout<<"Enter any five string (name) : \n";
- for(i=0; i<5; i++)
- {
- cin>>str[i];
- }
- for(i=1; i<5; i++)
- {
- for(j=1; j<5; j++)
- {
- if(strcmp(str[j-1], str[j])==1)
- {
- strcpy(t, str[j-1]);
- strcpy(str[j-1], str[j]);
- strcpy(str[j], t);
- }
- }
- cout<<endl;
- }
- cout<<endl<<"Strings (Names) in alphabetical order : \n";
- for(i=0; i<5; i++)
- {
- cout<<str[i]<<"\n";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement