#include <stdio.h>
#include <string.h>
void sortString(char *str);
int main() {
char str[100];
printf("Enter a string: ");
fgets(str, sizeof(str), stdin);
// Remove newline character from the input
if (str[strlen(str) - 1] == '\n') {
str[strlen(str) - 1] = '\0';
}
sortString(str);
printf("Sorted string: %s\n", str);
return 0;
}
void sortString(char *str) {
int n = strlen(str);
for (int i = 0; i < n - 1; i++) {
for (int j = i + 1; j < n; j++) {
if (str[i] > str[j]) {
// Swap characters if they are in the wrong order
char temp = str[i];
str[i] = str[j];
str[j] = temp;
}
}
}
}