Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main()
- {
- char str[100],temp;
- int l,i,j;
- printf("Enter a string.\n");
- fgets(str,sizeof(str),stdin);
- for(l=0;str[l]!='\0';l++)
- {}
- printf("\nIt has %d characters.\n",l-1);
- for (i = 0; i <(l-2); i++)
- {
- for (j = 0; j <(l-i-2); j++)
- {
- if (str[j] > str[j+1])
- {
- temp = str[j];
- str[j] = str[j+1];
- str[j+1] = temp;
- }
- }
- }
- printf("\nArranging alphabetically, we get %s.",str);
- return 0;
- }
- //Output
- //Enter a string.
- //programming
- //It has 11 characters.
- //Arranging alphabetically, we get aggimmnoprr.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement